Skip to content

Commit 6198193

Browse files
EmmyMayFajfa
authored andcommitted
Add options for adding records in different views
1 parent c8b5c25 commit 6198193

4 files changed

Lines changed: 54 additions & 7 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,18 +1995,22 @@ export default {
19951995
19961996
if (!(pageID || this.options.rowCreateUrl)) return
19971997
1998-
if (this.inModal) {
1998+
const route = {
1999+
name: this.options.rowCreateUrl || 'page.record.create',
2000+
params: { pageID, refRecord },
2001+
query: null,
2002+
}
2003+
2004+
if (this.inModal || this.options.addRecordDisplayOption === 'modal') {
19992005
this.$root.$emit('show-record-modal', {
20002006
recordID: NoID,
20012007
recordPageID: this.recordPageID,
20022008
refRecord,
20032009
})
2010+
} else if (this.options.addRecordDisplayOption === 'newTab') {
2011+
window.open(this.$router.resolve(route).href)
20042012
} else {
2005-
this.$router.push({
2006-
name: this.options.rowCreateUrl || 'page.record.create',
2007-
params: { pageID, refRecord },
2008-
query: null,
2009-
})
2013+
this.$router.push(route)
20102014
}
20112015
},
20122016

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@
593593
/>
594594
</b-form-group>
595595
</b-col>
596+
596597
<b-col
597598
cols="12"
598599
lg="6"
@@ -630,6 +631,22 @@
630631
<b-col
631632
cols="12"
632633
lg="6"
634+
>
635+
<b-form-group
636+
:label="$t('recordList.record.addRecordOptions')"
637+
label-class="text-primary"
638+
>
639+
<b-form-select
640+
v-model="options.addRecordDisplayOption"
641+
:options="recordCreateOptions"
642+
:disabled="options.hideAddButton"
643+
/>
644+
</b-form-group>
645+
</b-col>
646+
647+
<b-col
648+
cols="12"
649+
md="6"
633650
>
634651
<b-form-group
635652
:label="$t('recordList.record.editMode')"
@@ -881,6 +898,14 @@ export default {
881898
]
882899
},
883900
901+
recordCreateOptions () {
902+
return [
903+
{ value: 'sameTab', text: this.$t('recordList.record.createInSameTab') },
904+
{ value: 'newTab', text: this.$t('recordList.record.createInNewTab') },
905+
{ value: 'modal', text: this.$t('recordList.record.createInModal') },
906+
]
907+
},
908+
884909
moduleOptions () {
885910
return [
886911
{ moduleID: NoID, name: this.$t('general.label.none') },

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface Options {
3535
perPage: number;
3636
recordDisplayOption: string;
3737
recordSelectorDisplayOption: string;
38+
addRecordDisplayOption: string;
3839
magnifyOption: string;
3940

4041
fullPageNavigation: boolean;
@@ -95,6 +96,7 @@ const defaults: Readonly<Options> = Object.freeze({
9596
perPage: 20,
9697
recordDisplayOption: 'sameTab',
9798
recordSelectorDisplayOption: 'sameTab',
99+
addRecordDisplayOption: 'sameTab',
98100
magnifyOption: '',
99101

100102
fullPageNavigation: false,
@@ -140,7 +142,19 @@ export class PageBlockRecordList extends PageBlock {
140142
if (!o) return
141143

142144
Apply(this.options, o, CortezaID, 'moduleID')
143-
Apply(this.options, o, String, 'prefilter', 'presort', 'selectMode', 'positionField', 'refField', 'recordDisplayOption', 'magnifyOption', 'recordSelectorDisplayOption')
145+
146+
Apply(this.options, o, String,
147+
'prefilter',
148+
'presort',
149+
'selectMode',
150+
'positionField',
151+
'refField',
152+
'recordDisplayOption',
153+
'magnifyOption',
154+
'recordSelectorDisplayOption',
155+
'addRecordDisplayOption'
156+
)
157+
144158
Apply(this.options, o, Number, 'perPage', 'refreshRate')
145159

146160
if (o.fields) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@ recordList:
484484
openInSameTab: Open record in the same tab
485485
openInNewTab: Open record in a new tab
486486
openInModal: Open record in a modal
487+
createInSameTab: Create record in the same tab
488+
createInNewTab: Create record in a new tab
489+
createInModal: Create record in a modal
487490
enableBulkRecordEdit: Enable bulk record edit
488491
linkToParent: Link to parent record
489492
buttons: Record buttons
@@ -497,6 +500,7 @@ recordList:
497500
permissions: Permissions
498501
recordDisplayOptions: On record click
499502
recordSelectorDisplayOptions: On record selector click
503+
addRecordOptions: On add record click
500504
recordPage: record page
501505
refField:
502506
footnote: Field that links records with the parent record

0 commit comments

Comments
 (0)