Commit 596e64e5d7a51dbd03bceeb3e6e626781ef34134

Authored by Dmitriy Zaporozhets
1 parent 071de30f

Drop rjs from Notes#index

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/assets/javascripts/notes.js
... ... @@ -6,7 +6,7 @@ var NoteList = {
6 6 target_type: null,
7 7  
8 8 init: function(tid, tt, path) {
9   - NoteList.notes_path = path + ".js";
  9 + NoteList.notes_path = path + ".json";
10 10 NoteList.target_id = tid;
11 11 NoteList.target_type = tt;
12 12 NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id;
... ... @@ -411,7 +411,10 @@ var NoteList = {
411 411 data: NoteList.target_params,
412 412 complete: function(){ $('.js-notes-busy').removeClass("loading")},
413 413 beforeSend: function() { $('.js-notes-busy').addClass("loading") },
414   - dataType: "script"
  414 + success: function(data) {
  415 + NoteList.setContent(data.html);
  416 + },
  417 + dataType: "json"
415 418 });
416 419 },
417 420  
... ... @@ -419,7 +422,7 @@ var NoteList = {
419 422 * Called in response to getContent().
420 423 * Replaces the content of #notes-list with the given html.
421 424 */
422   - setContent: function(newNoteIds, html) {
  425 + setContent: function(html) {
423 426 $("#notes-list").html(html);
424 427 },
425 428  
... ...
app/controllers/projects/notes_controller.rb
... ... @@ -14,7 +14,20 @@ class Projects::NotesController &lt; Projects::ApplicationController
14 14 @discussions = discussions_from_notes
15 15 end
16 16  
17   - respond_with(@notes)
  17 + respond_to do |format|
  18 + format.html { redirect_to :back }
  19 + format.json do
  20 + html = render_to_string(
  21 + "projects/notes/_notes",
  22 + layout: false,
  23 + formats: [:html]
  24 + )
  25 +
  26 + render json: {
  27 + html: html,
  28 + }
  29 + end
  30 + end
18 31 end
19 32  
20 33 def create
... ...
app/views/projects/notes/index.js.haml
... ... @@ -1,4 +0,0 @@
1   -- unless @notes.blank?
2   - var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}";
3   - - new_note_ids = @notes.map(&:id)
4   - NoteList.setContent(#{new_note_ids}, notesHtml);
config/initializers/1_settings.rb
... ... @@ -30,7 +30,7 @@ class Settings &lt; Settingslogic
30 30 gitlab.relative_url_root
31 31 ].join('')
32 32 end
33   -
  33 +
34 34 # check that values in `current` (string or integer) is a contant in `modul`.
35 35 def verify_constant_array(modul, current, default)
36 36 values = default || []
... ...