Clean up the delete-menu stuff for Comments and Posts

This commit is contained in:
Wolfgang Huß 2019-05-19 08:23:51 +02:00
parent 2016a9445b
commit 7f83f775a7
7 changed files with 9 additions and 47 deletions

View File

@ -1,5 +1,6 @@
<template>
<div class="modal-wrapper">
<!-- Todo: Put all modals with 2 buttons and equal properties in one customiced 'danger-action-modal' -->
<disable-modal
v-if="open === 'disable'"
:id="data.resource.id"

View File

@ -75,66 +75,28 @@ export default {
},
methods: {
async cancel() {
if (!!this.cancelCallback) {
await this.cancelCallback()
}
this.isOpen = false
setTimeout(() => {
this.$emit('close')
if (!!this.cancelCallback) {
this.cancelCallback()
}
}, 1000)
},
async confirm() {
var gqlMutation
this.loading = true
try {
switch (this.type) {
case 'contribution':
// gqlMutation = gql`
// mutation($id: ID!) {
// DeletePost(id: $id) {
// id
// }
// }
// `
// await this.$apollo.mutate({
// mutation: gqlMutation,
// variables: { id: this.id }
// })
// this.$toast.success(this.$t(`delete.${this.type}.success`))
await this.confirmCallback()
break
case 'comment':
// XXX Make custom mutation and tests in the Backend !!!
await this.confirmCallback()
break
}
await this.confirmCallback()
this.success = true
setTimeout(() => {
this.isOpen = false
setTimeout(() => {
this.success = false
this.$emit('close')
switch (this.type) {
case 'contribution':
if (this.$router.history.current.name === 'post-id-slug') {
// redirect to index
// this.$router.history.push('/')
} else {
// reload the page (when deleting from profile or index)
// window.location.assign(window.location.href)
}
break
}
}, 500)
}, 1500)
} catch (err) {
this.success = false
// switch (this.type) {
// case 'contribution':
// this.$toast.error(err.message)
// break
// }
} finally {
this.loading = false
}

View File

@ -71,7 +71,6 @@ export default {
this.$apollo.queries.Post.refetch()
},
deleteComment(index) {
console.log('Remove comment event !!!')
this.comments.splice(index, 1)
}
},

View File

@ -16,7 +16,7 @@ export default {
variables: { id: this.post.id }
})
this.$toast.success(this.$t(`delete.contribution.success`))
this.$emit('delete')
this.$emit('deletePost')
} catch (err) {
this.$toast.error(err.message)
}

View File

@ -10,7 +10,7 @@
:key="post.id"
:post="post"
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
@delete="deletePost(index, post.id)"
@deletePost="deletePost(index, post.id)"
/>
</ds-flex>
<no-ssr>

View File

@ -40,7 +40,7 @@
:key="relatedPost.id"
:post="relatedPost"
:width="{ base: '100%', lg: 1 }"
@delete="deletePost(index)"
@deletePost="deletePost(index)"
/>
</ds-flex>
<hc-empty

View File

@ -295,7 +295,7 @@
:key="post.id"
:post="post"
:width="{ base: '100%', md: '100%', xl: '50%' }"
@delete="deletePost(index)"
@deletePost="deletePost(index)"
/>
</template>
<template v-else>