Got the go to Index Page to work on Post Page deletion

This commit is contained in:
Wolfgang Huß 2019-05-20 07:00:33 +02:00
parent 8d6e3794cf
commit 7e922fa0b0
3 changed files with 9 additions and 15 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)"
/>
</no-ssr>
@ -256,9 +256,6 @@ export default {
methods: {
isAuthor(id) {
return this.$store.getters['auth/user'].id === id
},
async deletePostOptionsCallback() {
await deletePostCallback(true)
}
}
}