Commit c20af32ae4adb1ec891e32ea048ae06ef4c7bc5f

Authored by Riyad Preukschas
1 parent 6fc10fa2

Pull together and rename Notes partials

app/views/notes/_common_form.html.haml
@@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
1 -= form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form" } do |f|  
2 -  
3 - = note_target_fields  
4 - = f.hidden_field :line_code  
5 - = f.hidden_field :noteable_id  
6 - = f.hidden_field :noteable_type  
7 -  
8 - - if @note.errors.any?  
9 - .alert-message.block-message.error  
10 - - @note.errors.full_messages.each do |msg|  
11 - %div= msg  
12 -  
13 - .note_text_and_preview.js-toggler-container  
14 - %a.js-note-preview-button.js-toggler-target.turn-on{ href: "javascript:;", data: {title: "Preview", url: preview_project_notes_path(@project)} }  
15 - %i.icon-eye-open  
16 - %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Edit"} }  
17 - %i.icon-edit  
18 -  
19 - = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on'  
20 - .note_preview.js-note-preview.turn-off  
21 -  
22 - .buttons  
23 - = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button"  
24 - %a.btn.grouped.js-close-discussion-note-form Cancel  
25 - .hint  
26 - .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.  
27 - .clearfix  
28 -  
29 - .note_options  
30 - .attachments.right  
31 - %h6.left Attachment:  
32 - %span.file_name File name...  
33 -  
34 - .input.input_file  
35 - %a.file_upload.btn.small Upload File  
36 - = f.file_field :attachment, class: "input-file"  
37 - %span.hint Any file less than 10 MB  
38 -  
39 - .notify_opts.right  
40 - %h6.left Notify via email:  
41 - = label_tag :notify do  
42 - = check_box_tag :notify, 1, !@note.for_commit?  
43 - %span Project team  
44 -  
45 - - if @note.notify_only_author?(current_user)  
46 - = label_tag :notify_author do  
47 - = check_box_tag :notify_author, 1 , !@note.for_commit?  
48 - %span Commit author  
49 - .clearfix  
app/views/notes/_create_common_note.js.haml
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -- if note.valid?  
2 - - if note.for_wall?  
3 - NoteList.appendNewWallNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}");  
4 - - else  
5 - NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}");  
6 -  
7 -- else  
8 - -# TODO: insert form correctly  
9 - $(".js-main-target-note").replaceWith("#{escape_javascript(render 'notes/common_form')}");  
10 - GitLab.GfmAutoComplete.setup();  
app/views/notes/_create_discussion_note.js.haml
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -- if note.valid?  
2 - :plain  
3 - NoteList.appendNewDiscussionNote("#{note.discussion_id}",  
4 - "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [note])}",  
5 - "#{escape_javascript(render "notes/note", note: note)}");  
app/views/notes/_form.html.haml 0 → 100644
@@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
  1 += form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form" } do |f|
  2 +
  3 + = note_target_fields
  4 + = f.hidden_field :line_code
  5 + = f.hidden_field :noteable_id
  6 + = f.hidden_field :noteable_type
  7 +
  8 + - if @note.errors.any?
  9 + .alert-message.block-message.error
  10 + - @note.errors.full_messages.each do |msg|
  11 + %div= msg
  12 +
  13 + .note_text_and_preview.js-toggler-container
  14 + %a.js-note-preview-button.js-toggler-target.turn-on{ href: "javascript:;", data: {title: "Preview", url: preview_project_notes_path(@project)} }
  15 + %i.icon-eye-open
  16 + %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Edit"} }
  17 + %i.icon-edit
  18 +
  19 + = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on'
  20 + .note_preview.js-note-preview.turn-off
  21 +
  22 + .buttons
  23 + = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button"
  24 + %a.btn.grouped.js-close-discussion-note-form Cancel
  25 + .hint
  26 + .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}.
  27 + .clearfix
  28 +
  29 + .note_options
  30 + .attachments.right
  31 + %h6.left Attachment:
  32 + %span.file_name File name...
  33 +
  34 + .input.input_file
  35 + %a.file_upload.btn.small Upload File
  36 + = f.file_field :attachment, class: "input-file"
  37 + %span.hint Any file less than 10 MB
  38 +
  39 + .notify_opts.right
  40 + %h6.left Notify via email:
  41 + = label_tag :notify do
  42 + = check_box_tag :notify, 1, !@note.for_commit?
  43 + %span Project team
  44 +
  45 + - if @note.notify_only_author?(current_user)
  46 + = label_tag :notify_author do
  47 + = check_box_tag :notify_author, 1 , !@note.for_commit?
  48 + %span Commit author
  49 + .clearfix
app/views/notes/_notes_with_form.html.haml
1 %ul#notes-list.notes 1 %ul#notes-list.notes
2 -.notes-status 2 +.js-notes-busy
3 3
4 .js-main-target-form 4 .js-main-target-form
5 - if can? current_user, :write_note, @project 5 - if can? current_user, :write_note, @project
6 - = render "notes/common_form" 6 + = render "notes/form"
7 7
8 :javascript 8 :javascript
9 $(function(){ 9 $(function(){
app/views/notes/_reversed_notes_with_form.html.haml
1 .js-main-target-form 1 .js-main-target-form
2 - if can? current_user, :write_note, @project 2 - if can? current_user, :write_note, @project
3 - = render "notes/common_form" 3 + = render "notes/form"
4 4
5 %ul#new-notes-list.reversed.notes 5 %ul#new-notes-list.reversed.notes
6 %ul#notes-list.reversed.notes 6 %ul#notes-list.reversed.notes
7 -.notes-status 7 +.notes-busy.js-notes-busy
8 8
9 :javascript 9 :javascript
10 $(function(){ 10 $(function(){
app/views/notes/create.js.haml
1 -- if note_for_main_target?(@note)  
2 - = render "create_common_note", note: @note 1 +- if @note.valid?
  2 + var noteHtml = "#{escape_javascript(render "notes/note", note: @note)}";
  3 +
  4 + - if note_for_main_target?(@note)
  5 + - if @note.for_wall?
  6 + NoteList.appendNewWallNote(#{@note.id}, noteHtml);
  7 + - else
  8 + NoteList.appendNewNote(#{@note.id}, noteHtml);
  9 + - else
  10 + var firstDiscussionNoteHtml = "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [@note])}";
  11 + NoteList.appendNewDiscussionNote("#{@note.discussion_id}", firstDiscussionNoteHtml, noteHtml);
  12 +
3 - else 13 - else
4 - = render "create_discussion_note", note: @note 14 + -# TODO: insert form correctly
  15 + $(".js-main-target-note").replaceWith("#{escape_javascript(render 'notes/common_form')}");
  16 + GitLab.GfmAutoComplete.setup();
5 \ No newline at end of file 17 \ No newline at end of file
app/views/notes/index.js.haml
1 - unless @notes.blank? 1 - unless @notes.blank?
  2 + var notesHtml = "#{escape_javascript(render 'notes/notes')}";
2 - new_note_ids = @notes.map(&:id) 3 - new_note_ids = @notes.map(&:id)
3 - if loading_more_notes? 4 - if loading_more_notes?
4 - :plain  
5 - NoteList.appendMoreNotes(#{new_note_ids}, "#{escape_javascript(render 'notes/notes')}"); 5 + NoteList.appendMoreNotes(#{new_note_ids}, notesHtml);
6 6
7 - elsif loading_new_notes? 7 - elsif loading_new_notes?
8 - :plain  
9 - NoteList.replaceNewNotes(#{new_note_ids}, "#{escape_javascript(render 'notes/notes')}"); 8 + NoteList.replaceNewNotes(#{new_note_ids}, notesHtml);
10 9
11 - else 10 - else
12 - :plain  
13 - NoteList.setContent(#{new_note_ids}, "#{escape_javascript(render 'notes/notes')}"); 11 + NoteList.setContent(#{new_note_ids}, notesHtml);
14 12
15 - else 13 - else
16 - if loading_more_notes? 14 - if loading_more_notes?
17 - :plain  
18 - NoteList.finishedLoadingMore(); 15 + NoteList.finishedLoadingMore();