diff --git a/client/web/compose/src/components/Common/RecordToolbar.vue b/client/web/compose/src/components/Common/RecordToolbar.vue
index 98b3a85ce..9023e389a 100644
--- a/client/web/compose/src/components/Common/RecordToolbar.vue
+++ b/client/web/compose/src/components/Common/RecordToolbar.vue
@@ -21,8 +21,7 @@
@click.prevent="$emit('back')"
>
{{ backLabel }}
diff --git a/client/web/compose/src/components/PageBlocks/RecordListBase.vue b/client/web/compose/src/components/PageBlocks/RecordListBase.vue
index 80a24ca96..129452578 100644
--- a/client/web/compose/src/components/PageBlocks/RecordListBase.vue
+++ b/client/web/compose/src/components/PageBlocks/RecordListBase.vue
@@ -4,7 +4,7 @@
v-bind="$props"
:scrollable-body="false"
v-on="$listeners"
- @refreshBlock="refresh(false, false)"
+ @refreshBlock="refresh(true, false)"
>
{
- return this.pullRecords(resetPagination)
- })
+ await this.$nextTick()
+ return this.pullRecords(resetPagination)
},
/**
@@ -1566,9 +1565,6 @@ export default {
const query = queryToFilter(this.query, this.drillDownFilter || this.prefilter, this.fields.map(({ moduleField }) => moduleField), this.recordListFilter)
const { moduleID, namespaceID } = this.recordListModule
- if (this.filter.pageCursor) {
- this.filter.sort = ''
- }
let paginationOptions = {}
if (resetPagination) {
@@ -1578,6 +1574,8 @@ export default {
incPageNavigation: fullPageNavigation,
incTotal: showTotalCount,
}
+ } else if (this.filter.pageCursor) {
+ this.filter.sort = ''
}
// Filter's out deleted records when filter.deleted is 2, and undeleted records when filter.deleted is 0
diff --git a/client/web/compose/src/components/Public/Record/Modal.vue b/client/web/compose/src/components/Public/Record/Modal.vue
index e8debaf1d..7f3f1b9a1 100644
--- a/client/web/compose/src/components/Public/Record/Modal.vue
+++ b/client/web/compose/src/components/Public/Record/Modal.vue
@@ -22,6 +22,7 @@
:page="page"
:module="module"
:record-i-d="recordID"
+ :values="values"
show-record-modal
@handle-record-redirect="loadRecord"
/>
@@ -69,6 +70,7 @@ export default {
recordID: undefined,
module: undefined,
page: undefined,
+ values: undefined,
}
},
@@ -116,7 +118,8 @@ export default {
clearRecordIDs: 'ui/clearRecordIDs',
}),
- loadRecord ({ recordID, recordPageID }) {
+ loadRecord ({ recordID, recordPageID, values }) {
+ this.values = values
this.loadModal({ recordID, recordPageID })
setTimeout(() => {
diff --git a/client/web/compose/src/mixins/record.js b/client/web/compose/src/mixins/record.js
index 95f3d76a6..018dd5c25 100644
--- a/client/web/compose/src/mixins/record.js
+++ b/client/web/compose/src/mixins/record.js
@@ -73,6 +73,7 @@ export default {
this.processingSubmit = true
this.processing = true
+ let record
const isNew = this.record.recordID === NoID
const queue = []
@@ -142,8 +143,8 @@ export default {
throw err
})
- .then(record => {
- this.record = new compose.Record(this.module, record)
+ .then(r => {
+ record = new compose.Record(this.module, r)
})
.then(() => this.dispatchUiEvent('afterFormSubmit', this.record, { $records: records }))
.then(() => this.updatePrompts())
@@ -151,8 +152,20 @@ export default {
if (this.record.valueErrors.set) {
this.toastWarning(this.$t('notification:record.validationWarnings'))
} else {
- this.inCreating = false
+ if (isNew) {
+ this.inCreating = false
+ this.inEditing = false
+ } else {
+ this.record = record
+ }
+
+ if (this.showRecordModal) {
+ this.$emit('handle-record-redirect', { recordID: record.recordID, recordPageID: this.page.pageID })
+ } else {
+ this.$router.push({ name: route, params: { ...this.$route.params, recordID: record.recordID } })
+ }
}
+
this.toastSuccess(this.$t(`notification:record.${isNew ? 'create' : 'update'}Success`))
})
.catch(this.toastErrorHandler(this.$t(`notification:record.${isNew ? 'create' : 'update'}Failed`)))
@@ -170,6 +183,7 @@ export default {
this.processingSubmit = true
this.processing = true
+ let record
const isNew = this.record.recordID === NoID
return this
@@ -192,15 +206,22 @@ export default {
throw err
})
- .then(record => {
- this.record = new compose.Record(this.module, record)
+ .then(r => {
+ record = new compose.Record(this.module, r)
})
- .then(() => this.dispatchUiEvent('beforeFormSubmit', this.record))
+ .then(() => this.dispatchUiEvent('afterFormSubmit', record))
.then(() => this.updatePrompts())
.then(() => {
if (this.record.valueErrors.set) {
this.toastWarning(this.$t('notification:record.validationWarnings'))
} else {
+ if (isNew) {
+ this.inCreating = false
+ this.inEditing = false
+ } else {
+ this.record = record
+ }
+
this.$router.push({ name: route, params: { ...this.$route.params, recordID: this.record.recordID } })
}
})
diff --git a/client/web/compose/src/views/Admin/Modules/Records/Create.vue b/client/web/compose/src/views/Admin/Modules/Records/Create.vue
index 4acac9bb1..d07543249 100644
--- a/client/web/compose/src/views/Admin/Modules/Records/Create.vue
+++ b/client/web/compose/src/views/Admin/Modules/Records/Create.vue
@@ -1,6 +1,5 @@
diff --git a/client/web/compose/src/views/Admin/Modules/Records/Edit.vue b/client/web/compose/src/views/Admin/Modules/Records/Edit.vue
index 2622c988a..4ead75430 100644
--- a/client/web/compose/src/views/Admin/Modules/Records/Edit.vue
+++ b/client/web/compose/src/views/Admin/Modules/Records/Edit.vue
@@ -13,20 +13,8 @@ export default {
data () {
return {
inEditing: true,
+ inCreating: false,
}
},
-
- computed: {
- title () {
- const { name, handle } = this.module
- return this.$t('allRecords.edit.title', { name: name || handle, interpolation: { escapeValue: false } })
- },
- },
-
- methods: {
- handleBack () {
- this.$router.push({ name: 'admin.modules.record.view' })
- },
- },
}
diff --git a/client/web/compose/src/views/Admin/Modules/Records/View.vue b/client/web/compose/src/views/Admin/Modules/Records/View.vue
index dd6dbec68..7a94ce0b2 100644
--- a/client/web/compose/src/views/Admin/Modules/Records/View.vue
+++ b/client/web/compose/src/views/Admin/Modules/Records/View.vue
@@ -102,7 +102,6 @@
diff --git a/client/web/compose/src/views/Public/Pages/Records/View.vue b/client/web/compose/src/views/Public/Pages/Records/View.vue
index fdf5a5f86..e6d31e561 100644
--- a/client/web/compose/src/views/Public/Pages/Records/View.vue
+++ b/client/web/compose/src/views/Public/Pages/Records/View.vue
@@ -157,6 +157,20 @@ export default {
default: '',
},
+ // When creating from related record blocks
+ refRecord: {
+ type: compose.Record,
+ required: false,
+ default: () => ({}),
+ },
+
+ // If component was called (via router) with some pre-seed values
+ values: {
+ type: Object,
+ required: false,
+ default: () => ({}),
+ },
+
// Open record in a modal
showRecordModal: {
type: Boolean,
@@ -343,7 +357,16 @@ export default {
this.handleBack()
})
} else {
- this.record = new compose.Record(module, {})
+ this.record = new compose.Record(module, { values: this.values })
+ }
+
+ if (this.refRecord) {
+ // Record create form called from a related records block,
+ // we'll try to find an appropriate field and cross-link this new record to ref
+ const recRefField = this.module.fields.find(f => f.kind === 'Record' && f.options.moduleID === this.refRecord.moduleID)
+ if (recRefField) {
+ this.record.values[recRefField.name] = this.refRecord.recordID
+ }
}
}
},
@@ -352,7 +375,12 @@ export default {
/**
* Not the best way since we can not always know where we
* came from (and "where" is back).
- */
+ */
+ if (this.showRecordModal) {
+ this.$bvModal.hide('record-modal')
+ return
+ }
+
const previousPage = await this.popPreviousPages()
const extraPop = !this.inCreating
this.$router.push(previousPage || { name: 'pages', params: { slug: this.namespace.slug || this.namespace.namespaceID } })
@@ -382,8 +410,7 @@ export default {
this.inEditing = true
this.inCreating = true
- this.record = new compose.Record(this.module, { values: this.record.values })
- this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID })
+ this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID, values: this.record.values })
},
handleEdit () {