Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js')
-rw-r--r--src/js/components/Comments/Comments.vue26
-rw-r--r--src/js/store/modules/comments.js30
-rw-r--r--src/js/views/Vote.vue3
3 files changed, 53 insertions, 6 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;
}
}
diff --git a/src/js/store/modules/comments.js b/src/js/store/modules/comments.js
index 129f7f2b..e0f032d5 100644
--- a/src/js/store/modules/comments.js
+++ b/src/js/store/modules/comments.js
@@ -43,8 +43,14 @@ const mutations = {
addComment(state, payload) {
state.list.push(payload)
- }
+ },
+ removeComment(state, payload) {
+ console.log('removeComment', payload)
+ state.list = state.list.filter(comment => {
+ return comment.id !== payload.comment.id
+ })
+ }
}
const getters = {
@@ -76,6 +82,28 @@ const actions = {
})
},
+ deleteComment(context, payload) {
+ let endPoint = 'apps/polls/comment/delete/'
+
+ if (context.rootState.acl.foundByToken) {
+ endPoint = endPoint.concat('s/')
+ }
+
+ return axios.post(OC.generateUrl(endPoint), {
+ token: context.rootState.acl.token,
+ comment: payload.comment
+ })
+ .then((response) => {
+ console.error('removed', response.data)
+ context.commit('removeComment', { comment: response.data.comment })
+ return response.data
+ }, (error) => {
+ console.error('Error deleting comment', { error: error.response }, { payload: payload })
+ throw error
+ })
+
+ },
+
setCommentAsync(context, payload) {
let endPoint = 'apps/polls/comment/write/'
diff --git a/src/js/views/Vote.vue b/src/js/views/Vote.vue
index 50d8663e..6c98e636 100644
--- a/src/js/views/Vote.vue
+++ b/src/js/views/Vote.vue
@@ -45,7 +45,6 @@
<Subscription />
<div class="additional">
<ParticipantsList v-if="acl.allowSeeUsernames" />
- <!-- <Comments /> -->
</div>
</div>
@@ -55,7 +54,6 @@
</template>
<script>
-// import Comments from '../components/Comments/Comments'
import { AppContent } from '@nextcloud/vue'
import Subscription from '../components/Subscription/Subscription'
import ParticipantsList from '../components/Base/ParticipantsList'
@@ -78,7 +76,6 @@ export default {
PollInformation,
PollTitle,
LoadingOverlay,
- // Comments,
SideBar,
VoteTable,
VoteList