diff --git a/app/assets/javascripts/line_comments/components/resolve_btn.js.coffee b/app/assets/javascripts/line_comments/components/resolve_btn.js.coffee index 3363f0a9854ef6130168017fd385ae179f563857..5ade02c56f52bcba690184cf8f449dd371a61837 100644 --- a/app/assets/javascripts/line_comments/components/resolve_btn.js.coffee +++ b/app/assets/javascripts/line_comments/components/resolve_btn.js.coffee @@ -19,7 +19,6 @@ compiled: -> $(this.$el).tooltip() destroyed: -> - console.log this.noteId + CommentsStore.delete(this.noteId) created: -> - console.log this.noteId CommentsStore.create(this.noteId, this.resolved) diff --git a/app/assets/javascripts/line_comments/stores/comments.js.coffee b/app/assets/javascripts/line_comments/stores/comments.js.coffee index c002dc0c4d658a7d6a6f868376247e6f7a3faf8d..ae44ab90290cbd6f3626526e1509d9ab2ac66108 100644 --- a/app/assets/javascripts/line_comments/stores/comments.js.coffee +++ b/app/assets/javascripts/line_comments/stores/comments.js.coffee @@ -4,6 +4,8 @@ Vue.set(this.state, id, resolved) update: (id, resolved) -> this.state[id] = resolved + delete: (id) -> + Vue.delete(this.state, id) updateAll: (state) -> for id,resolved of this.state this.update(id, state) if resolved isnt state diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index d4de712f88c741b64b938212b6a85b1e23b20eae..6c4c18c98c678ed72fbdf88d7404382577834173 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -271,6 +271,10 @@ class @Notes # append new note to all matching discussions discussionContainer.append note_html + if $('resolve-btn').length and DiffNotesApp? + $('resolve-btn').each -> + DiffNotesApp.$compile $(this).get(0) + gl.utils.localTimeAgo($('.js-timeago', note_html), false) @updateNotesCount(1) @@ -465,6 +469,12 @@ class @Notes note = $(el) notes = note.closest(".notes") + if DiffNotesApp? + ref = DiffNotesApp.$refs["#{noteId}"] + + if ref? + ref.$destroy(true) + # check if this is the last note for this line if notes.find(".note").length is 1 diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index ed304aef4dce519578b027726726a1f7666c31b8..0c42296e49264dc1db236c2b6d00686258f251fb 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -21,7 +21,7 @@ - if access and not note.system %span.note-role.hidden-xs= access - unless note.system - %resolve-btn{ ":note-id" => note.id, ":resolved" => "false", "inline-template" => true } + %resolve-btn{ ":note-id" => note.id, ":resolved" => "false", "inline-template" => true, "v-ref:note_#{note.id}" => true } %button.note-action-button.line-resolve-btn{ type: "button", ":class" => "{ 'is-active': isResolved }", ":aria-label" => "buttonText", "@click" => "resolve", ":title" => "buttonText" } = icon("check") - if current_user and not note.system