From 5c610a3a8d381dd77db568759baf0d6bfb3d2c82 Mon Sep 17 00:00:00 2001 From: Stuart Laverick Date: Tue, 3 Oct 2023 18:17:20 +0100 Subject: [PATCH] Improved handling of delete and order updates --- src/classes/Auth.js | 2 +- src/views/pages/Edit.vue | 14 ----------- src/views/pages/List.vue | 24 +++++++++++++++++++ src/views/pages/Show.vue | 5 ++++ .../update-requests/show/PageDetails.vue | 6 +++++ 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/classes/Auth.js b/src/classes/Auth.js index 9d92c3a0..d6f822c6 100644 --- a/src/classes/Auth.js +++ b/src/classes/Auth.js @@ -419,7 +419,7 @@ class Auth { return true; } if (type === "page") { - return this.isContentAdmin; + return this.isSuperAdmin; } if (type === "user") { return ( diff --git a/src/views/pages/Edit.vue b/src/views/pages/Edit.vue index 20266c54..69242a36 100644 --- a/src/views/pages/Edit.vue +++ b/src/views/pages/Edit.vue @@ -33,15 +33,6 @@ }} - - - - @@ -161,11 +152,6 @@ export default { } this.$router.push(next); }, - onDelete() { - this.$router.push({ - name: "pages-index", - }); - }, }, created() { this.fetchPage(); diff --git a/src/views/pages/List.vue b/src/views/pages/List.vue index 57c51b5a..4deba7c2 100644 --- a/src/views/pages/List.vue +++ b/src/views/pages/List.vue @@ -9,6 +9,10 @@ >page {{ updatedPage.title }} has been updated + {{ + orderChangedMessage + }} + @@ -138,6 +142,7 @@ export default { { value: "landing", text: "Landing page" }, ], updated: false, + orderChangedMessage: null, }; }, computed: { @@ -184,19 +189,35 @@ export default { this.loading = false; }, async onMoveUp(page) { + this.orderChangedMessage = null; + const orderWas = page.order; page.order--; await http.put(`/pages/${page.id}`, { id: page.id, order: page.order, }); + if (!this.auth.isSuperAdmin) { + this.orderChangedMessage = this.orderUpdateRequestMessage( + orderWas, + page + ); + } this.fetchPages(); }, async onMoveDown(page) { + this.orderChangedMessage = null; + const orderWas = page.order; page.order++; await http.put(`/pages/${page.id}`, { id: page.id, order: page.order, }); + if (!this.auth.isSuperAdmin) { + this.orderChangedMessage = this.orderUpdateRequestMessage( + orderWas, + page + ); + } this.fetchPages(); }, async onSearch() { @@ -227,6 +248,9 @@ export default { return parsed; }, + orderUpdateRequestMessage(orderWas, page) { + return `An update request has been created to change the order of page ${page.title} from ${orderWas} to ${page.order}`; + }, }, created() { this.updated = this.$route.query.updated || false; diff --git a/src/views/pages/Show.vue b/src/views/pages/Show.vue index ae27028c..5439f8d2 100644 --- a/src/views/pages/Show.vue +++ b/src/views/pages/Show.vue @@ -123,6 +123,11 @@ export default { this.loading = false; }, + onDelete() { + this.$router.push({ + name: "pages-index", + }); + }, }, created() { diff --git a/src/views/update-requests/show/PageDetails.vue b/src/views/update-requests/show/PageDetails.vue index 14670cdf..eb21642c 100644 --- a/src/views/update-requests/show/PageDetails.vue +++ b/src/views/update-requests/show/PageDetails.vue @@ -56,6 +56,12 @@ {{ page.enabled | status }} + + Order + {{ original.order }} + {{ page.order }} + + Content