From 96ede7f73191909e68156fba3e9e2c3f9a8e723f Mon Sep 17 00:00:00 2001 From: Fatih Acet Date: Fri, 16 Jun 2017 01:37:06 +0300 Subject: IssueNotesRefactor: Implement logic for delete action. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No backend request for now. It’s just client side logic. --- .../notes/components/issue_discussion.vue | 2 +- .../javascripts/notes/components/issue_note.vue | 23 +++++++++++++++-- .../notes/components/issue_note_actions.vue | 9 ++++++- .../notes/components/issue_system_note.vue | 4 +-- .../notes/services/issue_notes_service.js | 3 +++ .../javascripts/notes/stores/issue_notes_store.js | 30 +++++++++++++++++++--- 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/notes/components/issue_discussion.vue b/app/assets/javascripts/notes/components/issue_discussion.vue index 954a6e3b7ee..1f7707a5208 100644 --- a/app/assets/javascripts/notes/components/issue_discussion.vue +++ b/app/assets/javascripts/notes/components/issue_discussion.vue @@ -48,7 +48,7 @@ export default { this.$store.commit('toggleDiscussion', { discussionId: this.note.id, }); - } + }, }, }; diff --git a/app/assets/javascripts/notes/components/issue_note.vue b/app/assets/javascripts/notes/components/issue_note.vue index 191555fd979..3dc28d60ddd 100644 --- a/app/assets/javascripts/notes/components/issue_note.vue +++ b/app/assets/javascripts/notes/components/issue_note.vue @@ -14,6 +14,7 @@ export default { data() { return { isEditing: false, + isDeleting: false, }; }, components: { @@ -26,11 +27,28 @@ export default { author() { return this.note.author; }, + classNameBindings() { + return { + 'is-editing': this.isEditing, + 'disabled-content': this.isDeleting, + }; + }, }, methods: { editHandler() { this.isEditing = true; }, + deleteHandler() { + this.isDeleting = true; + this.$store + .dispatch('deleteNote', this.note) + .then(() => { + this.isDeleting = false; + }) + .catch(() => { + this.isDeleting = false; + }); + }, formUpdateHandler() { // console.log('update requested', data); }, @@ -44,7 +62,7 @@ export default {