From 57a307ef076e4d372e27313beccd8c2ff69857c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C5=BEe=20Fortun?= Date: Mon, 26 Feb 2024 14:16:28 +0100 Subject: [PATCH] Fix layout evaluating multiple times and defaulting to the current one after saving record --- client/web/compose/src/mixins/record.js | 6 +++--- .../web/compose/src/views/Public/Pages/Records/View.vue | 9 ++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/client/web/compose/src/mixins/record.js b/client/web/compose/src/mixins/record.js index afa97c02e5..b4f7f66a3a 100644 --- a/client/web/compose/src/mixins/record.js +++ b/client/web/compose/src/mixins/record.js @@ -175,11 +175,11 @@ export default { moduleID: this.module.moduleID, notPageID: this.page.pageID, }) - } else { - this.$router.push({ name: route, params: { ...this.$route.params, recordID: record.recordID } }) } - if (!isNew) { + if (isNew) { + this.$router.push({ name: route, params: { ...this.$route.params, recordID: record.recordID } }) + } else { this.record = record // reset the record initial state in cases where the record edit page is opened on a modal this.initialRecordState = this.record.clone() 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 d93da5eecd..e88d592afd 100644 --- a/client/web/compose/src/views/Public/Pages/Records/View.vue +++ b/client/web/compose/src/views/Public/Pages/Records/View.vue @@ -303,13 +303,10 @@ export default { watch: { recordID: { immediate: true, - handler () { + handler (o, n) { this.record = undefined this.initialRecordState = undefined this.refresh() - this.loadRecord().then(() => { - this.determineLayout() - }) }, }, @@ -524,7 +521,7 @@ export default { layout: undefined, isView: !this.inEditing && !this.inCreating, isCreate: this.inCreating, - isEdit: this.inEditing, + isEdit: this.inEditing && !this.inCreating, ...variables, } @@ -546,8 +543,6 @@ export default { }, async determineLayout (pageLayoutID, variables = {}) { - pageLayoutID = pageLayoutID || (this.layout || {}).pageLayoutID - // Clear stored records so they can be refetched with latest values this.clearRecordSet() let expressions = {}