From 7e922fa0b0c4f3d08615dfcc305005e9c3505f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 20 May 2019 07:00:33 +0200 Subject: [PATCH] Got the go to Index Page to work on Post Page deletion --- webapp/components/Modal/DeleteModal.vue | 4 ---- webapp/mixins/Post.js | 15 ++++++++------- webapp/pages/post/_id/_slug/index.vue | 5 +---- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/webapp/components/Modal/DeleteModal.vue b/webapp/components/Modal/DeleteModal.vue index 8f6c6400b..ace5d9097 100644 --- a/webapp/components/Modal/DeleteModal.vue +++ b/webapp/components/Modal/DeleteModal.vue @@ -84,13 +84,9 @@ export default { }, 1000) }, async confirm() { - console.log('"confirm" was reached !!!') this.loading = true try { - console.log('"confirmCallback" is: ', this.confirmCallback) await this.confirmCallback() - // this.confirmCallback() - console.log('"confirmCallback" was exec !!!') this.success = true setTimeout(() => { this.isOpen = false diff --git a/webapp/mixins/Post.js b/webapp/mixins/Post.js index 69c1b5426..24779bab1 100644 --- a/webapp/mixins/Post.js +++ b/webapp/mixins/Post.js @@ -2,7 +2,7 @@ import gql from 'graphql-tag' export default { methods: { - async deletePostCallback(listPageType = true) { + async deletePostCallback(postDisplayType = 'list') { try { var gqlMutation = gql` mutation($id: ID!) { @@ -16,12 +16,13 @@ export default { variables: { id: this.post.id } }) this.$toast.success(this.$t(`delete.contribution.success`)) - if (listPageType) { - console.log('Emit "deletePost" !!!') - this.$emit('deletePost') - } else { - console.log('Redirect to index !!!') - this.$router.history.push('/') // Single page type: redirect to index + switch (postDisplayType) { + case 'list': + this.$emit('deletePost') + break + default: + this.$router.history.push('/') // Single page type: Redirect to index + break } } catch (err) { this.$toast.error(err.message) diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index bede9c1c8..102d9007c 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -18,7 +18,7 @@ placement="bottom-end" resource-type="contribution" :resource="post" - :callbacks="{ confirm: deletePostOptionsCallback, cancel: null }" + :callbacks="{ confirm: () => deletePostCallback('page'), cancel: null }" :is-owner="isAuthor(post.author.id)" /> @@ -256,9 +256,6 @@ export default { methods: { isAuthor(id) { return this.$store.getters['auth/user'].id === id - }, - async deletePostOptionsCallback() { - await deletePostCallback(true) } } }