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'"
|
v-if="open === 'delete'"
|
||||||
:id="data.resource.id"
|
:id="data.resource.id"
|
||||||
:type="data.type"
|
:type="data.type"
|
||||||
:confirmCallback="data.callbacks.confirm"
|
:confirm-callback="data.callbacks.confirm"
|
||||||
:cancelCallback="!!data.callbacks.cancel ? data.callbacks.cancel : null"
|
:cancel-callback="!!data.callbacks.cancel ? data.callbacks.cancel : null"
|
||||||
:name="name"
|
:name="name"
|
||||||
@close="close"
|
@close="close"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -84,9 +84,13 @@ export default {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
},
|
},
|
||||||
async confirm() {
|
async confirm() {
|
||||||
|
console.log('"confirm" was reached !!!')
|
||||||
this.loading = true
|
this.loading = true
|
||||||
try {
|
try {
|
||||||
|
console.log('"confirmCallback" is: ', this.confirmCallback)
|
||||||
await this.confirmCallback()
|
await this.confirmCallback()
|
||||||
|
// this.confirmCallback()
|
||||||
|
console.log('"confirmCallback" was exec !!!')
|
||||||
this.success = true
|
this.success = true
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.isOpen = false
|
this.isOpen = false
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
async deletePostCallback() {
|
async deletePostCallback(listPageType = true) {
|
||||||
try {
|
try {
|
||||||
var gqlMutation = gql`
|
var gqlMutation = gql`
|
||||||
mutation($id: ID!) {
|
mutation($id: ID!) {
|
||||||
@ -16,7 +16,13 @@ export default {
|
|||||||
variables: { id: this.post.id }
|
variables: { id: this.post.id }
|
||||||
})
|
})
|
||||||
this.$toast.success(this.$t(`delete.contribution.success`))
|
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) {
|
} catch (err) {
|
||||||
this.$toast.error(err.message)
|
this.$toast.error(err.message)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
deletePost(_index, postId) {
|
deletePost(_index, postId) {
|
||||||
this.Post = this.Post.filter((post) => {
|
this.Post = this.Post.filter(post => {
|
||||||
return post.id !== postId
|
return post.id !== postId
|
||||||
})
|
})
|
||||||
// Ideal solution:
|
// Ideal solution:
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
placement="bottom-end"
|
placement="bottom-end"
|
||||||
resource-type="contribution"
|
resource-type="contribution"
|
||||||
:resource="post"
|
:resource="post"
|
||||||
:callbacks="{ confirm: deletePostCallback, cancel: null }"
|
:callbacks="{ confirm: deletePostOptionsCallback, cancel: null }"
|
||||||
:is-owner="isAuthor(post.author.id)"
|
:is-owner="isAuthor(post.author.id)"
|
||||||
/>
|
/>
|
||||||
</no-ssr>
|
</no-ssr>
|
||||||
@ -256,6 +256,9 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
isAuthor(id) {
|
isAuthor(id) {
|
||||||
return this.$store.getters['auth/user'].id === id
|
return this.$store.getters['auth/user'].id === id
|
||||||
|
},
|
||||||
|
async deletePostOptionsCallback() {
|
||||||
|
await deletePostCallback(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user