Commit a8927a75 authored by Phil Hughes's avatar Phil Hughes Committed by Douwe Maan

Fixed issue when adding or deleting through jQuery

parent 0ab8264e
......@@ -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)
......@@ -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
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment