From c20af32ae4adb1ec891e32ea048ae06ef4c7bc5f Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Sun, 2 Dec 2012 23:14:56 +0100 Subject: [PATCH] Pull together and rename Notes partials --- app/views/notes/_create_common_note.js.haml | 10 ---------- .../notes/_create_discussion_note.js.haml | 5 ----- ...{_common_form.html.haml => _form.html.haml} | 0 app/views/notes/_notes_with_form.html.haml | 4 ++-- .../notes/_reversed_notes_with_form.html.haml | 4 ++-- app/views/notes/create.js.haml | 18 +++++++++++++++--- app/views/notes/index.js.haml | 13 +++++-------- 7 files changed, 24 insertions(+), 30 deletions(-) delete mode 100644 app/views/notes/_create_common_note.js.haml delete mode 100644 app/views/notes/_create_discussion_note.js.haml rename app/views/notes/{_common_form.html.haml => _form.html.haml} (100%) diff --git a/app/views/notes/_create_common_note.js.haml b/app/views/notes/_create_common_note.js.haml deleted file mode 100644 index 7ea8c4cd..00000000 --- a/app/views/notes/_create_common_note.js.haml +++ /dev/null @@ -1,10 +0,0 @@ -- if note.valid? - - if note.for_wall? - NoteList.appendNewWallNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}"); - - else - NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}"); - -- else - -# TODO: insert form correctly - $(".js-main-target-note").replaceWith("#{escape_javascript(render 'notes/common_form')}"); - GitLab.GfmAutoComplete.setup(); diff --git a/app/views/notes/_create_discussion_note.js.haml b/app/views/notes/_create_discussion_note.js.haml deleted file mode 100644 index 3a6c3dad..00000000 --- a/app/views/notes/_create_discussion_note.js.haml +++ /dev/null @@ -1,5 +0,0 @@ -- if note.valid? - :plain - NoteList.appendNewDiscussionNote("#{note.discussion_id}", - "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [note])}", - "#{escape_javascript(render "notes/note", note: note)}"); diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_form.html.haml similarity index 100% rename from app/views/notes/_common_form.html.haml rename to app/views/notes/_form.html.haml diff --git a/app/views/notes/_notes_with_form.html.haml b/app/views/notes/_notes_with_form.html.haml index 2511cbe5..2566edd8 100644 --- a/app/views/notes/_notes_with_form.html.haml +++ b/app/views/notes/_notes_with_form.html.haml @@ -1,9 +1,9 @@ %ul#notes-list.notes -.notes-status +.js-notes-busy .js-main-target-form - if can? current_user, :write_note, @project - = render "notes/common_form" + = render "notes/form" :javascript $(function(){ diff --git a/app/views/notes/_reversed_notes_with_form.html.haml b/app/views/notes/_reversed_notes_with_form.html.haml index 6a7f08f9..bb583b8c 100644 --- a/app/views/notes/_reversed_notes_with_form.html.haml +++ b/app/views/notes/_reversed_notes_with_form.html.haml @@ -1,10 +1,10 @@ .js-main-target-form - if can? current_user, :write_note, @project - = render "notes/common_form" + = render "notes/form" %ul#new-notes-list.reversed.notes %ul#notes-list.reversed.notes -.notes-status +.notes-busy.js-notes-busy :javascript $(function(){ diff --git a/app/views/notes/create.js.haml b/app/views/notes/create.js.haml index 03aec54b..6ffb0cde 100644 --- a/app/views/notes/create.js.haml +++ b/app/views/notes/create.js.haml @@ -1,4 +1,16 @@ -- if note_for_main_target?(@note) - = render "create_common_note", note: @note +- if @note.valid? + var noteHtml = "#{escape_javascript(render "notes/note", note: @note)}"; + + - if note_for_main_target?(@note) + - if @note.for_wall? + NoteList.appendNewWallNote(#{@note.id}, noteHtml); + - else + NoteList.appendNewNote(#{@note.id}, noteHtml); + - else + var firstDiscussionNoteHtml = "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [@note])}"; + NoteList.appendNewDiscussionNote("#{@note.discussion_id}", firstDiscussionNoteHtml, noteHtml); + - else - = render "create_discussion_note", note: @note + -# TODO: insert form correctly + $(".js-main-target-note").replaceWith("#{escape_javascript(render 'notes/common_form')}"); + GitLab.GfmAutoComplete.setup(); \ No newline at end of file diff --git a/app/views/notes/index.js.haml b/app/views/notes/index.js.haml index ae70dcad..f0826100 100644 --- a/app/views/notes/index.js.haml +++ b/app/views/notes/index.js.haml @@ -1,18 +1,15 @@ - unless @notes.blank? + var notesHtml = "#{escape_javascript(render 'notes/notes')}"; - new_note_ids = @notes.map(&:id) - if loading_more_notes? - :plain - NoteList.appendMoreNotes(#{new_note_ids}, "#{escape_javascript(render 'notes/notes')}"); + NoteList.appendMoreNotes(#{new_note_ids}, notesHtml); - elsif loading_new_notes? - :plain - NoteList.replaceNewNotes(#{new_note_ids}, "#{escape_javascript(render 'notes/notes')}"); + NoteList.replaceNewNotes(#{new_note_ids}, notesHtml); - else - :plain - NoteList.setContent(#{new_note_ids}, "#{escape_javascript(render 'notes/notes')}"); + NoteList.setContent(#{new_note_ids}, notesHtml); - else - if loading_more_notes? - :plain - NoteList.finishedLoadingMore(); + NoteList.finishedLoadingMore();