Commit 918dc873 authored by Riyad Preukschas's avatar Riyad Preukschas

Move code for appending a discussion note to notes JS

parent fac4e3f2
...@@ -377,6 +377,20 @@ var NoteList = { ...@@ -377,6 +377,20 @@ var NoteList = {
this.updateVotes(); this.updateVotes();
}, },
appendNewDiscussionNote: function(discussionId, diffRowHtml, noteHtml) {
// is this the first note of discussion?
var row = $("form[rel='"+discussionId+"']").closest("tr");
if (row.is(".js-temp-notes-holder")) {
// insert the note and the reply button after it
row.after(diffRowHtml);
// will be added again below
row.next().find(".note").remove();
}
// append new note to all matching discussions
$(".notes[rel='"+discussionId+"']").append(noteHtml);
},
/** /**
* Recalculates the votes and updates them (if they are displayed at all). * Recalculates the votes and updates them (if they are displayed at all).
* *
......
- if note.valid? - if note.valid?
:plain :plain
// is this the first note of discussion? NoteList.appendNewDiscussionNote("#{note.discussion_id}",
var row = $("form[rel='#{note.discussion_id}']").closest("tr"); "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [note])}",
if (row.is(".js-temp-notes-holder")) { "#{escape_javascript(render "notes/note", note: note)}");
// insert the note and the reply button after it
row.after("#{escape_javascript(render "notes/diff_notes_with_reply", notes: [note])}");
// will be added again below
row.next().find(".note").remove();
}
// append new note to all discussions
$(".notes[rel='#{note.discussion_id}']").append("#{escape_javascript(render "notes/note", note: note)}");
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