Skip to content

Commit

Permalink
Allow records to be opened in edit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmyMay committed Mar 20, 2024
1 parent 9fcfe86 commit 579599a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
24 changes: 15 additions & 9 deletions client/web/compose/src/components/PageBlocks/RecordListBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
:key="`${index}${item.r.recordID}`"
:class="{ 'pointer': !(options.editable && editing), }"
:variant="inlineEditing && item.r.deletedAt ? 'warning' : ''"
@click="handleRowClicked(item)"
@click="handleRowClick(item)"
>
<b-td
v-if="options.draggable && inlineEditing"
Expand Down Expand Up @@ -435,6 +435,7 @@
:icon="['fas', 'ellipsis-v']"
/>
</template>

<template v-if="inlineEditing">
<b-dropdown-item
v-if="isCloneRecordActionVisible"
Expand Down Expand Up @@ -1456,7 +1457,7 @@ export default {
this.processing = false
},
handleRowClicked ({ r: { recordID } }) {
handleRowClick ({ r: { recordID } }) {
if ((this.options.editable && this.editing) || (!this.recordPageID && !this.options.rowViewUrl)) {
return
}
Expand All @@ -1470,22 +1471,27 @@ 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 name = this.options.openRecordInEditMode ? this.options.rowEditUrl || 'page.record.edit' : this.options.rowViewUrl || 'page.record'
const route = {
name: this.options.rowViewUrl || 'page.record',
name,
params: {
pageID,
recordID,
},
query: null,
}
if (this.options.recordDisplayOption === 'modal' || this.inModal) {
this.$root.$emit('show-record-modal', {
recordID,
recordPageID: this.recordPageID,
})
} else if (this.options.recordDisplayOption === 'newTab') {
if (this.options.recordDisplayOption === 'newTab') {
window.open(this.$router.resolve(route).href)
} else {
this.$router.push(route)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,22 @@
</b-form-group>
</b-col>

<b-col
cols="12"
md="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"
Expand Down
13 changes: 8 additions & 5 deletions lib/js/src/compose/types/page-block/record-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,26 @@ export interface Options {
positionField?: string;
refField?: string;
editFields?: unknown[];

// When adding a new record, link it to parent when available
linkToParent: boolean;

// Should records be opened in a new tab
// legacy field that has been removed but we keep it for backwards compatibility
openInNewTab: boolean;

// Are table rows selectable
selectable: boolean;
selectMode: 'multi' | 'single' | 'range';

// Ordered list of buttons to display in the block
selectionButtons: Array<Button>;

bulkRecordEditEnabled: boolean;
inlineRecordEditEnabled: boolean;
filterPresets: FilterPreset[];
showRecordPerPageOption: boolean;
openRecordInEditMode: boolean;
}

const defaults: Readonly<Options> = Object.freeze({
Expand Down Expand Up @@ -122,6 +123,7 @@ const defaults: Readonly<Options> = Object.freeze({
inlineRecordEditEnabled: false,
filterPresets: [],
showRecordPerPageOption: false,
openRecordInEditMode: false,
})

export class PageBlockRecordList extends PageBlock {
Expand Down Expand Up @@ -185,6 +187,7 @@ export class PageBlockRecordList extends PageBlock {
'bulkRecordEditEnabled',
'inlineRecordEditEnabled',
'showRecordPerPageOption',
'openRecordInEditMode',
)

if (o.selectionButtons) {
Expand Down
1 change: 1 addition & 0 deletions locale/en/corteza-webapp-compose/block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ recordList:
withPresortedRecords: with presorted ({{0}}) record
record:
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
hideAddButton: Users will be able to add new records
hideImportButton: Users will be able to import records
Expand Down

0 comments on commit 579599a

Please sign in to comment.