From adbb10222afc468547821dbfb644e4bb6b406b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C5=BEe=20Fortun?= Date: Wed, 26 Jul 2023 16:01:35 +0200 Subject: [PATCH] Fix new view/edit record flow for module all records --- .../src/views/Admin/Modules/Records/View.vue | 9 +++- .../src/views/Public/Pages/Records/View.vue | 46 ++++++++----------- 2 files changed, 27 insertions(+), 28 deletions(-) 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 0cc6e340c..dd6dbec68 100644 --- a/client/web/compose/src/views/Admin/Modules/Records/View.vue +++ b/client/web/compose/src/views/Admin/Modules/Records/View.vue @@ -88,6 +88,7 @@ @add="handleAdd()" @clone="handleClone()" @edit="handleEdit()" + @view="handleView()" @delete="handleDelete()" @undelete="handleUndelete()" @back="handleBack()" @@ -258,7 +259,13 @@ export default { }, handleEdit () { - this.$router.push({ name: 'admin.modules.record.edit', params: this.$route.params }) + this.inEditing = true + this.inCreating = false + }, + + handleView () { + this.inEditing = false + this.inCreating = false }, handleRedirectToPrevOrNext (recordID) { 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 b31970dfa..fdf5a5f86 100644 --- a/client/web/compose/src/views/Public/Pages/Records/View.vue +++ b/client/web/compose/src/views/Public/Pages/Records/View.vue @@ -287,7 +287,7 @@ export default { } else { this.recordNavigation = { prev: undefined, - next: undefined + next: undefined, } } }, @@ -353,45 +353,37 @@ export default { * Not the best way since we can not always know where we * came from (and "where" is back). */ - if (this.showRecordModal) { - if (!this.inEditing || this.inCreating) { - this.$bvModal.hide('record-modal') - } - this.inEditing = false - this.inCreating = false - } else { - const previousPage = await this.popPreviousPages() - const extraPop = !this.inCreating - this.$router.push(previousPage || { name: 'pages', params: { slug: this.namespace.slug || this.namespace.namespaceID } }) - // Pop an additional time so that the route we went back to isn't added to previousPages - if (extraPop) { - this.popPreviousPages() - } + const previousPage = await this.popPreviousPages() + const extraPop = !this.inCreating + this.$router.push(previousPage || { name: 'pages', params: { slug: this.namespace.slug || this.namespace.namespaceID } }) + // Pop an additional time so that the route we went back to isn't added to previousPages + if (extraPop) { + this.popPreviousPages() } }, handleAdd () { + if (!this.showRecordModal) { + this.$router.push({ name: 'page.record.create', params: this.newRouteParams }) + return + } + this.inEditing = true this.inCreating = true this.record = new compose.Record(this.module, { values: this.values }) - - if (this.showRecordModal) { - this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID }) - } else { - this.$router.push({ name: 'page.record.create', params: this.newRouteParams }) - } + this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID }) }, handleClone () { + if (!this.showRecordModal) { + this.$router.push({ name: 'page.record.create', params: { pageID: this.page.pageID, values: this.record.values } }) + return + } + this.inEditing = true this.inCreating = true this.record = new compose.Record(this.module, { values: this.record.values }) - - if (this.showRecordModal) { - this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID }) - } else { - this.$router.push({ name: 'page.record.create', params: { pageID: this.page.pageID, values: this.record.values } }) - } + this.$emit('handle-record-redirect', { recordID: NoID, recordPageID: this.page.pageID }) }, handleEdit () {