Skip to content

Commit c8b5c25

Browse files
EmmyMayFajfa
authored andcommitted
Allow records to be opened in edit mode
1 parent 5558920 commit c8b5c25

4 files changed

Lines changed: 40 additions & 14 deletions

File tree

client/web/compose/src/components/PageBlocks/RecordListBase.vue

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
:key="`${index}${item.r.recordID}`"
322322
:class="{ 'pointer': !(options.editable && editing), }"
323323
:variant="inlineEditing && item.r.deletedAt ? 'warning' : ''"
324-
@click="handleRowClicked(item)"
324+
@click="handleRowClick(item)"
325325
>
326326
<b-td
327327
v-if="options.draggable && inlineEditing"
@@ -435,6 +435,7 @@
435435
:icon="['fas', 'ellipsis-v']"
436436
/>
437437
</template>
438+
438439
<template v-if="inlineEditing">
439440
<b-dropdown-item
440441
v-if="isCloneRecordActionVisible"
@@ -1466,7 +1467,7 @@ export default {
14661467
this.processing = false
14671468
},
14681469
1469-
handleRowClicked ({ r: { recordID } }) {
1470+
handleRowClick ({ r: { recordID } }) {
14701471
if ((this.options.editable && this.editing) || (!this.recordPageID && !this.options.rowViewUrl)) {
14711472
return
14721473
}
@@ -1480,22 +1481,27 @@ export default {
14801481
})
14811482
}
14821483
1484+
if (this.options.recordDisplayOption === 'modal' || this.inModal) {
1485+
this.$root.$emit('show-record-modal', {
1486+
recordID,
1487+
recordPageID: this.recordPageID,
1488+
edit: this.options.openRecordInEditMode,
1489+
})
1490+
return
1491+
}
1492+
14831493
const pageID = this.recordPageID
1494+
const name = this.options.openRecordInEditMode ? this.options.rowEditUrl || 'page.record.edit' : this.options.rowViewUrl || 'page.record'
14841495
const route = {
1485-
name: this.options.rowViewUrl || 'page.record',
1496+
name,
14861497
params: {
14871498
pageID,
14881499
recordID,
14891500
},
14901501
query: null,
14911502
}
14921503
1493-
if (this.options.recordDisplayOption === 'modal' || this.inModal) {
1494-
this.$root.$emit('show-record-modal', {
1495-
recordID,
1496-
recordPageID: this.recordPageID,
1497-
})
1498-
} else if (this.options.recordDisplayOption === 'newTab') {
1504+
if (this.options.recordDisplayOption === 'newTab') {
14991505
window.open(this.$router.resolve(route).href)
15001506
} else {
15011507
this.$router.push(route)

client/web/compose/src/components/PageBlocks/RecordListConfigurator.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,22 @@
630630
<b-col
631631
cols="12"
632632
lg="6"
633+
>
634+
<b-form-group
635+
:label="$t('recordList.record.editMode')"
636+
label-class="text-primary"
637+
>
638+
<c-input-checkbox
639+
v-model="options.openRecordInEditMode"
640+
switch
641+
:labels="checkboxLabel"
642+
/>
643+
</b-form-group>
644+
</b-col>
645+
646+
<b-col
647+
cols="12"
648+
md="6"
633649
>
634650
<b-form-group
635651
:label="$t('recordList.selectable')"

lib/js/src/compose/types/page-block/record-list.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,26 @@ export interface Options {
5050
positionField?: string;
5151
refField?: string;
5252
editFields?: unknown[];
53-
53+
5454
// When adding a new record, link it to parent when available
5555
linkToParent: boolean;
56-
56+
5757
// Should records be opened in a new tab
5858
// legacy field that has been removed but we keep it for backwards compatibility
5959
openInNewTab: boolean;
60-
60+
6161
// Are table rows selectable
6262
selectable: boolean;
6363
selectMode: 'multi' | 'single' | 'range';
64-
64+
6565
// Ordered list of buttons to display in the block
6666
selectionButtons: Array<Button>;
67-
67+
6868
bulkRecordEditEnabled: boolean;
6969
inlineRecordEditEnabled: boolean;
7070
filterPresets: FilterPreset[];
7171
showRecordPerPageOption: boolean;
72+
openRecordInEditMode: boolean;
7273
}
7374

7475
const defaults: Readonly<Options> = Object.freeze({
@@ -122,6 +123,7 @@ const defaults: Readonly<Options> = Object.freeze({
122123
inlineRecordEditEnabled: false,
123124
filterPresets: [],
124125
showRecordPerPageOption: false,
126+
openRecordInEditMode: false,
125127
})
126128

127129
export class PageBlockRecordList extends PageBlock {
@@ -185,6 +187,7 @@ export class PageBlockRecordList extends PageBlock {
185187
'bulkRecordEditEnabled',
186188
'inlineRecordEditEnabled',
187189
'showRecordPerPageOption',
190+
'openRecordInEditMode',
188191
)
189192

190193
if (o.selectionButtons) {

locale/en/corteza-webapp-compose/block.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ recordList:
451451
withPresortedRecords: with presorted ({{0}}) record
452452
record:
453453
draggable: Can drag & drop records to order them
454+
editMode: Users will be able to open record in edit mode when a row is clicked
454455
fullPageNavigation: Full page navigation
455456
hideAddButton: Users will be able to add new records
456457
hideImportButton: Users will be able to import records

0 commit comments

Comments
 (0)