mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Go ahead with refactoring of DeleteModal in Comments and Posts
This commit is contained in:
parent
9af8c2b46c
commit
388e9ff6b2
@ -1,4 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<ds-flex-item
|
||||||
|
:width="width"
|
||||||
|
>
|
||||||
<ds-card
|
<ds-card
|
||||||
:header="post.title"
|
:header="post.title"
|
||||||
:image="post.image"
|
:image="post.image"
|
||||||
@ -71,6 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ds-card>
|
</ds-card>
|
||||||
|
</ds-flex-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -91,6 +95,10 @@ export default {
|
|||||||
post: {
|
post: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ 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')
|
this.$emit('delete')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.$toast.error(err.message)
|
this.$toast.error(err.message)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,13 +5,13 @@
|
|||||||
:width="{ base: '100%' }"
|
:width="{ base: '100%' }"
|
||||||
gutter="base"
|
gutter="base"
|
||||||
>
|
>
|
||||||
<ds-flex-item
|
<hc-post-card
|
||||||
v-for="post in uniq(Post)"
|
v-for="(post, index) in uniq(Post)"
|
||||||
:key="post.id"
|
:key="post.id"
|
||||||
|
:post="post"
|
||||||
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
|
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
|
||||||
>
|
@delete="deletePost(index, post.id)"
|
||||||
<hc-post-card :post="post" />
|
/>
|
||||||
</ds-flex-item>
|
|
||||||
</ds-flex>
|
</ds-flex>
|
||||||
<no-ssr>
|
<no-ssr>
|
||||||
<ds-button
|
<ds-button
|
||||||
@ -85,6 +85,14 @@ export default {
|
|||||||
},
|
},
|
||||||
fetchPolicy: 'cache-and-network'
|
fetchPolicy: 'cache-and-network'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
deletePost(_index, postId) {
|
||||||
|
console.log('Pages/index.vue: Post item deleted !!!')
|
||||||
|
this.Post = this.Post.filter((post) => {
|
||||||
|
return post.id !== postId
|
||||||
|
})
|
||||||
|
// Ideal sulution:
|
||||||
|
// this.Post.splice(index, 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
|
|||||||
@ -35,13 +35,13 @@
|
|||||||
v-if="post.relatedContributions && post.relatedContributions.length"
|
v-if="post.relatedContributions && post.relatedContributions.length"
|
||||||
gutter="small"
|
gutter="small"
|
||||||
>
|
>
|
||||||
<ds-flex-item
|
<hc-post-card
|
||||||
v-for="relatedPost in post.relatedContributions"
|
v-for="(relatedPost, index) in post.relatedContributions"
|
||||||
:key="relatedPost.id"
|
:key="relatedPost.id"
|
||||||
:width="{ base: '100%', lg: 1 }"
|
:width="{ base: '100%', lg: 1 }"
|
||||||
>
|
:post="relatedPost"
|
||||||
<hc-post-card :post="relatedPost" />
|
@delete="deletePost(index)"
|
||||||
</ds-flex-item>
|
/>
|
||||||
</ds-flex>
|
</ds-flex>
|
||||||
<hc-empty
|
<hc-empty
|
||||||
v-else
|
v-else
|
||||||
@ -73,6 +73,12 @@ export default {
|
|||||||
return this.Post ? this.Post[0] || {} : {}
|
return this.Post ? this.Post[0] || {} : {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
deletePost(index) {
|
||||||
|
console.log('Post/more-info.vue: Post item deleted !!!')
|
||||||
|
this.post.relatedContributions.splice(index, 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
Post: {
|
Post: {
|
||||||
query() {
|
query() {
|
||||||
|
|||||||
@ -290,13 +290,13 @@
|
|||||||
/>
|
/>
|
||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
<template v-if="activePosts.length">
|
<template v-if="activePosts.length">
|
||||||
<ds-flex-item
|
<hc-post-card
|
||||||
v-for="post in activePosts"
|
v-for="(post, index) in activePosts"
|
||||||
:key="post.id"
|
:key="post.id"
|
||||||
|
:post="post"
|
||||||
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
:width="{ base: '100%', md: '100%', xl: '50%' }"
|
||||||
>
|
@delete="deletePost(index)"
|
||||||
<hc-post-card :post="post" />
|
/>
|
||||||
</ds-flex-item>
|
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<ds-flex-item :width="{ base: '100%' }">
|
<ds-flex-item :width="{ base: '100%' }">
|
||||||
@ -404,6 +404,9 @@ export default {
|
|||||||
throw new Error('User not found!')
|
throw new Error('User not found!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// activePosts(activePosts) {
|
||||||
|
// this.activePosts = activePosts || []
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
uniq(items, field = 'id') {
|
uniq(items, field = 'id') {
|
||||||
@ -434,6 +437,10 @@ export default {
|
|||||||
},
|
},
|
||||||
fetchPolicy: 'cache-and-network'
|
fetchPolicy: 'cache-and-network'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
deletePost(index) {
|
||||||
|
this.user.contributions.splice(index, 1)
|
||||||
|
// this.$router.history.push('/')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user