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 @@ ...@@ -19,7 +19,6 @@
compiled: -> compiled: ->
$(this.$el).tooltip() $(this.$el).tooltip()
destroyed: -> destroyed: ->
console.log this.noteId CommentsStore.delete(this.noteId)
created: -> created: ->
console.log this.noteId
CommentsStore.create(this.noteId, this.resolved) CommentsStore.create(this.noteId, this.resolved)
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
Vue.set(this.state, id, resolved) Vue.set(this.state, id, resolved)
update: (id, resolved) -> update: (id, resolved) ->
this.state[id] = resolved this.state[id] = resolved
delete: (id) ->
Vue.delete(this.state, id)
updateAll: (state) -> updateAll: (state) ->
for id,resolved of this.state for id,resolved of this.state
this.update(id, state) if resolved isnt state this.update(id, state) if resolved isnt state
...@@ -271,6 +271,10 @@ class @Notes ...@@ -271,6 +271,10 @@ class @Notes
# append new note to all matching discussions # append new note to all matching discussions
discussionContainer.append note_html 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) gl.utils.localTimeAgo($('.js-timeago', note_html), false)
@updateNotesCount(1) @updateNotesCount(1)
...@@ -465,6 +469,12 @@ class @Notes ...@@ -465,6 +469,12 @@ class @Notes
note = $(el) note = $(el)
notes = note.closest(".notes") 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 # check if this is the last note for this line
if notes.find(".note").length is 1 if notes.find(".note").length is 1
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- if access and not note.system - if access and not note.system
%span.note-role.hidden-xs= access %span.note-role.hidden-xs= access
- unless note.system - 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" } %button.note-action-button.line-resolve-btn{ type: "button", ":class" => "{ 'is-active': isResolved }", ":aria-label" => "buttonText", "@click" => "resolve", ":title" => "buttonText" }
= icon("check") = icon("check")
- if current_user and not note.system - 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