diff options
author | René Gieling <github@dartcafe.de> | 2020-01-26 20:55:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-26 20:55:22 +0300 |
commit | 3b2695e62217acb084bd12c8ac9d4d6cad980972 (patch) | |
tree | aa750cd5cefbb7a66f98d1e7332041697c71903f /src/js/components | |
parent | a428b645d80b5f2d63e1fcfac0b8bfa5d0819dd4 (diff) | |
parent | 09e8d4b95f81340263504477392d2878a8cdbc1a (diff) |
Merge pull request #786 from nextcloud/deleteCommentsv1.2.0-beta
Delete comments
Diffstat (limited to 'src/js/components')
-rw-r--r-- | src/js/components/Comments/Comments.vue | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/js/components/Comments/Comments.vue b/src/js/components/Comments/Comments.vue index 9c43ffa8..24f118bb 100644 --- a/src/js/components/Comments/Comments.vue +++ b/src/js/components/Comments/Comments.vue @@ -29,15 +29,22 @@ <li v-for="(comment) in sortedList" :key="comment.id"> <div class="comment-item"> <user-div :user-id="comment.userId" /> + <Actions v-if="comment.userId === acl.userId"> + <ActionButton icon="icon-delete" @click="deleteComment(comment)"> + {{ t('polls', 'Delete comment') }} + </ActionButton> + </Actions> <div class="date"> {{ moment.utc(comment.dt).fromNow() }} </div> </div> + <div class="message wordwrap comment-content"> {{ comment.comment }} </div> </li> </transition-group> + <div v-else class="emptycontent"> <div class="icon-comment" /> <p> {{ t('polls', 'No comments yet. Be the first.') }}</p> @@ -47,12 +54,15 @@ <script> import CommentAdd from './CommentAdd' -import { mapState, mapGetters } from 'vuex' import sortBy from 'lodash/sortBy' +import { Actions, ActionButton } from '@nextcloud/vue' +import { mapState, mapGetters } from 'vuex' export default { name: 'Comments', components: { + Actions, + ActionButton, CommentAdd }, data() { @@ -80,6 +90,18 @@ export default { } } + }, + + methods: { + deleteComment(comment) { + this.$store.dispatch({ type: 'deleteComment', comment: comment }) + .then(() => { + OC.Notification.showTemporary(t('polls', 'Comment deleted'), { type: 'success' }) + }, (error) => { + OC.Notification.showTemporary(t('polls', 'Error while deleting Comment'), { type: 'error' }) + console.error(error.response) + }) + } } } </script> @@ -108,7 +130,7 @@ ul { } } & > .message { - margin-left: 44px; + margin-left: 53px; flex: 1 1; } } |