Hide new CommentForm while editing a comment

This commit is contained in:
mattwr18 2019-10-21 16:08:01 +02:00
parent 46fd534a28
commit 6d1044d292
3 changed files with 15 additions and 2 deletions

View File

@ -149,6 +149,7 @@ export default {
}, },
editCommentMenu(showMenu) { editCommentMenu(showMenu) {
this.openEditCommentMenu = showMenu this.openEditCommentMenu = showMenu
this.$emit('toggleNewCommentForm', !showMenu)
}, },
updateComment(comment) { updateComment(comment) {
this.$emit('updateComment', comment) this.$emit('updateComment', comment)

View File

@ -25,6 +25,7 @@
:routeHash="routeHash" :routeHash="routeHash"
@deleteComment="updateCommentList" @deleteComment="updateCommentList"
@updateComment="updateCommentList" @updateComment="updateCommentList"
@toggleNewCommentForm="toggleNewCommentForm"
/> />
</div> </div>
</div> </div>
@ -51,6 +52,9 @@ export default {
return comment.id === updatedComment.id ? updatedComment : comment return comment.id === updatedComment.id ? updatedComment : comment
}) })
}, },
toggleNewCommentForm(showNewCommentForm) {
this.$emit('toggleNewCommentForm', showNewCommentForm)
},
}, },
} }
</script> </script>

View File

@ -70,9 +70,13 @@
</ds-space> </ds-space>
<!-- Comments --> <!-- Comments -->
<ds-section slot="footer"> <ds-section slot="footer">
<hc-comment-list :post="post" :routeHash="$route.hash" /> <hc-comment-list
:post="post"
:routeHash="$route.hash"
@toggleNewCommentForm="toggleNewCommentForm"
/>
<ds-space margin-bottom="large" /> <ds-space margin-bottom="large" />
<hc-comment-form :post="post" @createComment="createComment" /> <hc-comment-form v-if="showNewCommentForm" :post="post" @createComment="createComment" />
</ds-section> </ds-section>
</ds-card> </ds-card>
</transition> </transition>
@ -119,6 +123,7 @@ export default {
post: null, post: null,
ready: false, ready: false,
title: 'loading', title: 'loading',
showNewCommentForm: true,
} }
}, },
watch: { watch: {
@ -181,6 +186,9 @@ export default {
}) })
.catch(error => this.$toast.error(error.message)) .catch(error => this.$toast.error(error.message))
}, },
toggleNewCommentForm(showNewCommentForm) {
this.showNewCommentForm = showNewCommentForm
},
}, },
apollo: { apollo: {
Post: { Post: {