3
0

Allow records to be opened in edit mode

This commit is contained in:
Emmy Leke 2024-02-19 17:23:48 +01:00 committed by Jože Fortun
parent 144eb912fb
commit 262a70015b
4 changed files with 35 additions and 9 deletions

View File

@ -321,7 +321,7 @@
:key="`${index}${item.r.recordID}`" :key="`${index}${item.r.recordID}`"
:class="{ 'pointer': !(options.editable && editing), }" :class="{ 'pointer': !(options.editable && editing), }"
:variant="inlineEditing && item.r.deletedAt ? 'warning' : ''" :variant="inlineEditing && item.r.deletedAt ? 'warning' : ''"
@click="handleRowClicked(item)" @click="handleRowClick(item)"
> >
<b-td <b-td
v-if="options.draggable && inlineEditing" v-if="options.draggable && inlineEditing"
@ -435,6 +435,7 @@
:icon="['fas', 'ellipsis-v']" :icon="['fas', 'ellipsis-v']"
/> />
</template> </template>
<template v-if="inlineEditing"> <template v-if="inlineEditing">
<b-dropdown-item <b-dropdown-item
v-if="isCloneRecordActionVisible" v-if="isCloneRecordActionVisible"
@ -1462,7 +1463,7 @@ export default {
this.processing = false this.processing = false
}, },
handleRowClicked ({ r: { recordID } }) { handleRowClick ({ r: { recordID } }) {
if ((this.options.editable && this.editing) || (!this.recordPageID && !this.options.rowViewUrl)) { if ((this.options.editable && this.editing) || (!this.recordPageID && !this.options.rowViewUrl)) {
return return
} }
@ -1476,9 +1477,19 @@ export default {
}) })
} }
if (this.options.recordDisplayOption === 'modal' || this.inModal) {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: this.recordPageID,
edit: this.options.openRecordInEditMode,
})
return
}
const pageID = this.recordPageID const pageID = this.recordPageID
const name = this.options.openRecordInEditMode ? this.options.rowEditUrl || 'page.record.edit' : this.options.rowViewUrl || 'page.record'
const route = { const route = {
name: this.options.rowViewUrl || 'page.record', name,
params: { params: {
pageID, pageID,
recordID, recordID,
@ -1486,12 +1497,7 @@ export default {
query: null, query: null,
} }
if (this.options.recordDisplayOption === 'modal' || this.inModal) { if (this.options.recordDisplayOption === 'newTab') {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: this.recordPageID,
})
} else if (this.options.recordDisplayOption === 'newTab') {
window.open(this.$router.resolve(route).href) window.open(this.$router.resolve(route).href)
} else { } else {
this.$router.push(route) this.$router.push(route)

View File

@ -619,6 +619,22 @@
<b-col <b-col
cols="12" cols="12"
lg="6" lg="6"
>
<b-form-group
:label="$t('recordList.record.editMode')"
label-class="text-primary"
>
<c-input-checkbox
v-model="options.openRecordInEditMode"
switch
:labels="checkboxLabel"
/>
</b-form-group>
</b-col>
<b-col
cols="12"
md="6"
> >
<b-form-group <b-form-group
:label="$t('recordList.selectable')" :label="$t('recordList.selectable')"

View File

@ -67,6 +67,7 @@ export interface Options {
inlineRecordEditEnabled: boolean; inlineRecordEditEnabled: boolean;
filterPresets: FilterPreset[]; filterPresets: FilterPreset[];
showRecordPerPageOption: boolean; showRecordPerPageOption: boolean;
openRecordInEditMode: boolean;
} }
const defaults: Readonly<Options> = Object.freeze({ const defaults: Readonly<Options> = Object.freeze({
@ -120,6 +121,7 @@ const defaults: Readonly<Options> = Object.freeze({
inlineRecordEditEnabled: false, inlineRecordEditEnabled: false,
filterPresets: [], filterPresets: [],
showRecordPerPageOption: false, showRecordPerPageOption: false,
openRecordInEditMode: false,
}) })
export class PageBlockRecordList extends PageBlock { export class PageBlockRecordList extends PageBlock {
@ -183,6 +185,7 @@ export class PageBlockRecordList extends PageBlock {
'bulkRecordEditEnabled', 'bulkRecordEditEnabled',
'inlineRecordEditEnabled', 'inlineRecordEditEnabled',
'showRecordPerPageOption', 'showRecordPerPageOption',
'openRecordInEditMode',
) )
if (o.selectionButtons) { if (o.selectionButtons) {

View File

@ -465,6 +465,7 @@ recordList:
withPresortedRecords: with presorted ({{0}}) record withPresortedRecords: with presorted ({{0}}) record
record: record:
draggable: Can drag & drop records to order them draggable: Can drag & drop records to order them
editMode: Users will be able to open record in edit mode when a row is clicked
fullPageNavigation: Full page navigation fullPageNavigation: Full page navigation
hideAddButton: Users will be able to add new records hideAddButton: Users will be able to add new records
hideImportButton: Users will be able to import records hideImportButton: Users will be able to import records