diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index defbf81f580..e39bfc0f792 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -6,7 +6,7 @@ var NoteList = { target_type: null, init: function(tid, tt, path) { - NoteList.notes_path = path + ".js"; + NoteList.notes_path = path + ".json"; NoteList.target_id = tid; NoteList.target_type = tt; NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id; @@ -411,7 +411,10 @@ var NoteList = { data: NoteList.target_params, complete: function(){ $('.js-notes-busy').removeClass("loading")}, beforeSend: function() { $('.js-notes-busy').addClass("loading") }, - dataType: "script" + success: function(data) { + NoteList.setContent(data.html); + }, + dataType: "json" }); }, @@ -419,7 +422,7 @@ var NoteList = { * Called in response to getContent(). * Replaces the content of #notes-list with the given html. */ - setContent: function(newNoteIds, html) { + setContent: function(html) { $("#notes-list").html(html); }, diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 8214163c315..dc479a9c755 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -14,7 +14,20 @@ class Projects::NotesController < Projects::ApplicationController @discussions = discussions_from_notes end - respond_with(@notes) + respond_to do |format| + format.html { redirect_to :back } + format.json do + html = render_to_string( + "projects/notes/_notes", + layout: false, + formats: [:html] + ) + + render json: { + html: html, + } + end + end end def create diff --git a/app/views/projects/notes/index.js.haml b/app/views/projects/notes/index.js.haml deleted file mode 100644 index 6c4ed203497..00000000000 --- a/app/views/projects/notes/index.js.haml +++ /dev/null @@ -1,4 +0,0 @@ -- unless @notes.blank? - var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}"; - - new_note_ids = @notes.map(&:id) - NoteList.setContent(#{new_note_ids}, notesHtml); diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 06e05714fdf..2b13bb51e02 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -30,7 +30,7 @@ class Settings < Settingslogic gitlab.relative_url_root ].join('') end - + # check that values in `current` (string or integer) is a contant in `modul`. def verify_constant_array(modul, current, default) values = default || []