diff options
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 11 | ||||
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 12 |
2 files changed, 20 insertions, 3 deletions
diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index a41ee67a841..d146d66b6c9 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -142,8 +142,15 @@ class Notes # remove the note (will be added again below) row.next().find(".note").remove() - # append new note to all matching discussions - $(".notes[rel='" + note.discussion_id + "']").append note.html + # Add note to 'Changes' page discussions + $(".notes[rel='" + note.discussion_id + "']").append note.html + + # Init discussion on 'Discussion' page + $('ul.main-notes-list').append(note.discussion_with_diff_html) + + else + # append new note to all matching discussions + $(".notes[rel='" + note.discussion_id + "']").append note.html # cleanup after successfully creating a diff/discussion note @removeDiscussionNoteForm(form) diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 5df92b29eda..fca4c2f652d 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -85,12 +85,22 @@ class Projects::NotesController < Projects::ApplicationController ) end + def note_to_discussion_with_diff_html(note) + render_to_string( + "projects/notes/_discussion", + layout: false, + formats: [:html], + locals: { discussion_notes: [note] } + ) + end + def render_note_json(note) render json: { id: note.id, discussion_id: note.discussion_id, html: note_to_html(note), - discussion_html: note_to_discussion_html(note) + discussion_html: note_to_discussion_html(note), + discussion_with_diff_html: note_to_discussion_with_diff_html(note) } end |