mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
64 lines
1.5 KiB
Vue
64 lines
1.5 KiB
Vue
<template>
|
|
<div id="comments" class="comment-list">
|
|
<h3 class="title">
|
|
<counter-icon icon="comments" :count="post.comments.length" />
|
|
{{ $t('common.comment', null, 0) }}
|
|
</h3>
|
|
<div v-if="post.comments && post.comments.length" id="comments" class="comments">
|
|
<comment-card
|
|
v-for="comment in post.comments"
|
|
:key="comment.id"
|
|
:comment="comment"
|
|
:postId="post.id"
|
|
@deleteComment="updateCommentList"
|
|
@updateComment="updateCommentList"
|
|
@toggleNewCommentForm="toggleNewCommentForm"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import CounterIcon from '~/components/_new/generic/CounterIcon/CounterIcon'
|
|
import CommentCard from '~/components/CommentCard/CommentCard'
|
|
import scrollToAnchor from '~/mixins/scrollToAnchor'
|
|
|
|
export default {
|
|
mixins: [scrollToAnchor],
|
|
components: {
|
|
CounterIcon,
|
|
CommentCard,
|
|
},
|
|
props: {
|
|
post: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
},
|
|
methods: {
|
|
checkAnchor(anchor) {
|
|
return anchor === '#comments'
|
|
},
|
|
updateCommentList(updatedComment) {
|
|
this.post.comments = this.post.comments.map(comment => {
|
|
return comment.id === updatedComment.id ? updatedComment : comment
|
|
})
|
|
},
|
|
toggleNewCommentForm(showNewCommentForm) {
|
|
this.$emit('toggleNewCommentForm', showNewCommentForm)
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.comment-list {
|
|
> .title {
|
|
margin-top: 0;
|
|
|
|
> .counter-icon {
|
|
margin-right: $space-small;
|
|
}
|
|
}
|
|
}
|
|
</style>
|