mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
First proof of functionality for Delete Comment and Post via DeleteModal
This commit is contained in:
parent
7f83f775a7
commit
f5d9bc9ae4
@ -19,8 +19,8 @@
|
||||
v-if="open === 'delete'"
|
||||
:id="data.resource.id"
|
||||
:type="data.type"
|
||||
:confirmCallback="data.callbacks.confirm"
|
||||
:cancelCallback="!!data.callbacks.cancel ? data.callbacks.cancel : null"
|
||||
:confirm-callback="data.callbacks.confirm"
|
||||
:cancel-callback="!!data.callbacks.cancel ? data.callbacks.cancel : null"
|
||||
:name="name"
|
||||
@close="close"
|
||||
/>
|
||||
|
||||
@ -84,9 +84,13 @@ 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
|
||||
|
||||
@ -2,7 +2,7 @@ import gql from 'graphql-tag'
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
async deletePostCallback() {
|
||||
async deletePostCallback(listPageType = true) {
|
||||
try {
|
||||
var gqlMutation = gql`
|
||||
mutation($id: ID!) {
|
||||
@ -16,7 +16,13 @@ export default {
|
||||
variables: { id: this.post.id }
|
||||
})
|
||||
this.$toast.success(this.$t(`delete.contribution.success`))
|
||||
this.$emit('deletePost')
|
||||
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
|
||||
}
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ export default {
|
||||
})
|
||||
},
|
||||
deletePost(_index, postId) {
|
||||
this.Post = this.Post.filter((post) => {
|
||||
this.Post = this.Post.filter(post => {
|
||||
return post.id !== postId
|
||||
})
|
||||
// Ideal solution:
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
placement="bottom-end"
|
||||
resource-type="contribution"
|
||||
:resource="post"
|
||||
:callbacks="{ confirm: deletePostCallback, cancel: null }"
|
||||
:callbacks="{ confirm: deletePostOptionsCallback, cancel: null }"
|
||||
:is-owner="isAuthor(post.author.id)"
|
||||
/>
|
||||
</no-ssr>
|
||||
@ -256,6 +256,9 @@ export default {
|
||||
methods: {
|
||||
isAuthor(id) {
|
||||
return this.$store.getters['auth/user'].id === id
|
||||
},
|
||||
async deletePostOptionsCallback() {
|
||||
await deletePostCallback(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user