diff --git a/client/web/compose/src/components/Chart/index.vue b/client/web/compose/src/components/Chart/index.vue index 87dcb7c77..afae18834 100644 --- a/client/web/compose/src/components/Chart/index.vue +++ b/client/web/compose/src/components/Chart/index.vue @@ -75,8 +75,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/Common/Grid.vue b/client/web/compose/src/components/Common/Grid.vue index f2920c834..1a44e2476 100644 --- a/client/web/compose/src/components/Common/Grid.vue +++ b/client/web/compose/src/components/Common/Grid.vue @@ -146,8 +146,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/PageBlocks/ChartBase.vue b/client/web/compose/src/components/PageBlocks/ChartBase.vue index e19b0e9c4..2578f17e2 100644 --- a/client/web/compose/src/components/PageBlocks/ChartBase.vue +++ b/client/web/compose/src/components/PageBlocks/ChartBase.vue @@ -58,8 +58,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/PageBlocks/MetricBase.vue b/client/web/compose/src/components/PageBlocks/MetricBase.vue index 4bbe7cb68..fb1ef2509 100644 --- a/client/web/compose/src/components/PageBlocks/MetricBase.vue +++ b/client/web/compose/src/components/PageBlocks/MetricBase.vue @@ -95,8 +95,8 @@ export default { beforeDestroy () { this.abortRequests() - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, created () { diff --git a/client/web/compose/src/components/PageBlocks/ProgressBase.vue b/client/web/compose/src/components/PageBlocks/ProgressBase.vue index eb2a209f5..ee10b123d 100644 --- a/client/web/compose/src/components/PageBlocks/ProgressBase.vue +++ b/client/web/compose/src/components/PageBlocks/ProgressBase.vue @@ -81,8 +81,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/PageBlocks/RecordListBase.vue b/client/web/compose/src/components/PageBlocks/RecordListBase.vue index b1417ab07..9da128c93 100644 --- a/client/web/compose/src/components/PageBlocks/RecordListBase.vue +++ b/client/web/compose/src/components/PageBlocks/RecordListBase.vue @@ -1194,9 +1194,9 @@ export default { * at the given point in time. * * It: - * * assures that local records have a sequencial indexing - * * appends aditional meta fields - * * resolves payloadediting + * * assures that local records have a sequential indexing + * * appends additional meta fields + * * resolves payload editing */ resolveRecords (resolve) { this.ctr = 0 diff --git a/client/web/compose/src/components/PageBlocks/RecordOrganizerBase.vue b/client/web/compose/src/components/PageBlocks/RecordOrganizerBase.vue index c8c50dc62..59f58bff3 100644 --- a/client/web/compose/src/components/PageBlocks/RecordOrganizerBase.vue +++ b/client/web/compose/src/components/PageBlocks/RecordOrganizerBase.vue @@ -255,8 +255,8 @@ export default { beforeDestroy () { this.abortRequests() - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/PageBlocks/TabsConfigurator.vue b/client/web/compose/src/components/PageBlocks/TabsConfigurator.vue index 91b01f926..aae23e20a 100644 --- a/client/web/compose/src/components/PageBlocks/TabsConfigurator.vue +++ b/client/web/compose/src/components/PageBlocks/TabsConfigurator.vue @@ -312,8 +312,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/Public/Page/Attachment/Modal.vue b/client/web/compose/src/components/Public/Page/Attachment/Modal.vue index 82cf852c5..6b13f2e43 100644 --- a/client/web/compose/src/components/Public/Page/Attachment/Modal.vue +++ b/client/web/compose/src/components/Public/Page/Attachment/Modal.vue @@ -75,8 +75,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/Public/Page/Block/Modal.vue b/client/web/compose/src/components/Public/Page/Block/Modal.vue index d311d14c8..a55e4679c 100644 --- a/client/web/compose/src/components/Public/Page/Block/Modal.vue +++ b/client/web/compose/src/components/Public/Page/Block/Modal.vue @@ -89,8 +89,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/components/Public/Record/Modal.vue b/client/web/compose/src/components/Public/Record/Modal.vue index ca71dd2f5..d8f12af0d 100644 --- a/client/web/compose/src/components/Public/Record/Modal.vue +++ b/client/web/compose/src/components/Public/Record/Modal.vue @@ -115,8 +115,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/mixins/record.js b/client/web/compose/src/mixins/record.js index 0f39a6d87..edc488b06 100644 --- a/client/web/compose/src/mixins/record.js +++ b/client/web/compose/src/mixins/record.js @@ -88,6 +88,7 @@ export default { queue.push(p) } }) + const pairs = await Promise.all(queue) for (const p of pairs) { @@ -103,18 +104,26 @@ export default { // Construct batch record payload const records = pairs.reduce((acc, cur) => { - acc.push({ - refField: cur.refField, - set: cur.items - .map(({ r }) => r) - .filter(({ deletedAt, recordID }) => recordID !== NoID || !deletedAt), - module: cur.module, - idPrefix: cur.idPrefix, - }) + if (cur.idPrefix) { + // If same module exists, use latest to avoid stale data + const existingIndex = acc.findIndex(({ module }) => module.moduleID === cur.module.moduleID) + if (existingIndex !== -1) { + acc[existingIndex].set = cur.items.map(({ r }) => r).filter(({ deletedAt, recordID }) => recordID !== NoID || !deletedAt) + } else { + acc.push({ + refField: cur.refField, + set: cur.items.map(({ r }) => r).filter(({ deletedAt, recordID }) => recordID !== NoID || !deletedAt), + module: cur.module, + idPrefix: cur.idPrefix, + }) + } + } + return acc }, []) const { recordID = NoID } = this.record || {} + // Append after the payload construction, so it is not presented as a // sub record. pairs.push({ @@ -152,15 +161,19 @@ export default { if (this.record.valueErrors.set) { this.toastWarning(this.$t('notification:record.validationWarnings')) } else { - this.inCreating = false - this.inEditing = false - 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 } }) } + + // Refresh record + this.inCreating = false + this.inEditing = false + this.record = undefined + this.loadRecord().then(() => { + this.determineLayout() + }) } this.toastSuccess(this.$t(`notification:record.${isNew ? 'create' : 'update'}Success`)) diff --git a/client/web/compose/src/views/Admin/Pages/Builder.vue b/client/web/compose/src/views/Admin/Pages/Builder.vue index d54e2e1e7..b08bc4f2e 100644 --- a/client/web/compose/src/views/Admin/Pages/Builder.vue +++ b/client/web/compose/src/views/Admin/Pages/Builder.vue @@ -512,8 +512,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { diff --git a/client/web/compose/src/views/Layout.vue b/client/web/compose/src/views/Layout.vue index 5afe445c4..ba30e26f8 100644 --- a/client/web/compose/src/views/Layout.vue +++ b/client/web/compose/src/views/Layout.vue @@ -192,8 +192,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: { 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 efef9c283..e0149c36a 100644 --- a/client/web/compose/src/views/Public/Pages/Records/View.vue +++ b/client/web/compose/src/views/Public/Pages/Records/View.vue @@ -317,8 +317,8 @@ export default { beforeDestroy () { this.abortRequests() - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, // Destroy event before route leave to ensure it doesn't destroy the newly created one diff --git a/client/web/compose/src/views/Public/Pages/View.vue b/client/web/compose/src/views/Public/Pages/View.vue index c441b5ab4..ea3fbce2a 100644 --- a/client/web/compose/src/views/Public/Pages/View.vue +++ b/client/web/compose/src/views/Public/Pages/View.vue @@ -197,8 +197,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, beforeRouteLeave (to, from, next) { diff --git a/lib/vue/src/components/permissions/CPermissionsModal.vue b/lib/vue/src/components/permissions/CPermissionsModal.vue index 72fe9d25c..319f74ef2 100644 --- a/lib/vue/src/components/permissions/CPermissionsModal.vue +++ b/lib/vue/src/components/permissions/CPermissionsModal.vue @@ -334,8 +334,8 @@ export default { }, beforeDestroy () { - this.setDefaultValues() this.destroyEvents() + this.setDefaultValues() }, methods: {