Skip to content

Commit

Permalink
Add options for adding records in different views
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmyMay committed Mar 20, 2024
1 parent 579599a commit 125e8c4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 7 deletions.
16 changes: 10 additions & 6 deletions client/web/compose/src/components/PageBlocks/RecordListBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1984,18 +1984,22 @@ export default {
if (!(pageID || this.options.rowCreateUrl)) return
if (this.inModal) {
const route = {
name: this.options.rowCreateUrl || 'page.record.create',
params: { pageID, refRecord },
query: null,
}
if (this.inModal || this.options.addRecordDisplayOption === 'modal') {
this.$root.$emit('show-record-modal', {
recordID: NoID,
recordPageID: this.recordPageID,
refRecord,
})
} else if (this.options.addRecordDisplayOption === 'newTab') {
window.open(this.$router.resolve(route).href)
} else {
this.$router.push({
name: this.options.rowCreateUrl || 'page.record.create',
params: { pageID, refRecord },
query: null,
})
this.$router.push(route)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
Expand Down Expand Up @@ -627,6 +628,22 @@
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
>
<b-form-group
:label="$t('recordList.record.addRecordOptions')"
label-class="text-primary"
>
<b-form-select
v-model="options.addRecordDisplayOption"
:options="recordCreateOptions"
:disabled="options.hideAddButton"
/>
</b-form-group>
</b-col>

<b-col
cols="12"
md="6"
Expand Down Expand Up @@ -881,6 +898,14 @@ export default {
]
},
recordCreateOptions () {
return [
{ value: 'sameTab', text: this.$t('recordList.record.createInSameTab') },
{ value: 'newTab', text: this.$t('recordList.record.createInNewTab') },
{ value: 'modal', text: this.$t('recordList.record.createInModal') },
]
},
moduleOptions () {
return [
{ moduleID: NoID, name: this.$t('general.label.none') },
Expand Down
16 changes: 15 additions & 1 deletion lib/js/src/compose/types/page-block/record-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface Options {
perPage: number;
recordDisplayOption: string;
recordSelectorDisplayOption: string;
addRecordDisplayOption: string;
magnifyOption: string;

fullPageNavigation: boolean;
Expand Down Expand Up @@ -95,6 +96,7 @@ const defaults: Readonly<Options> = Object.freeze({
perPage: 20,
recordDisplayOption: 'sameTab',
recordSelectorDisplayOption: 'sameTab',
addRecordDisplayOption: 'sameTab',
magnifyOption: '',

fullPageNavigation: false,
Expand Down Expand Up @@ -140,7 +142,19 @@ export class PageBlockRecordList extends PageBlock {
if (!o) return

Apply(this.options, o, CortezaID, 'moduleID')
Apply(this.options, o, String, 'prefilter', 'presort', 'selectMode', 'positionField', 'refField', 'recordDisplayOption', 'magnifyOption', 'recordSelectorDisplayOption')

Apply(this.options, o, String,
'prefilter',
'presort',
'selectMode',
'positionField',
'refField',
'recordDisplayOption',
'magnifyOption',
'recordSelectorDisplayOption',
'addRecordDisplayOption'
)

Apply(this.options, o, Number, 'perPage', 'refreshRate')

if (o.fields) {
Expand Down
4 changes: 4 additions & 0 deletions locale/en/corteza-webapp-compose/block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ recordList:
openInSameTab: Open record in the same tab
openInNewTab: Open record in a new tab
openInModal: Open record in a modal
createInSameTab: Create record in the same tab
createInNewTab: Create record in a new tab
createInModal: Create record in a modal
enableBulkRecordEdit: Enable bulk record edit
linkToParent: Link to parent record
buttons: Record buttons
Expand All @@ -497,6 +500,7 @@ recordList:
permissions: Permissions
recordDisplayOptions: On record click
recordSelectorDisplayOptions: On record selector click
addRecordOptions: On add record click
recordPage: record page
refField:
footnote: Field that links records with the parent record
Expand Down

0 comments on commit 125e8c4

Please sign in to comment.