diff --git a/app/views/notes/_common_form.html.haml b/app/views/notes/_common_form.html.haml deleted file mode 100644 index 9d60044..0000000 --- a/app/views/notes/_common_form.html.haml +++ /dev/null @@ -1,49 +0,0 @@ -= form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form" } do |f| - - = note_target_fields - = f.hidden_field :line_code - = f.hidden_field :noteable_id - = f.hidden_field :noteable_type - - - if @note.errors.any? - .alert-message.block-message.error - - @note.errors.full_messages.each do |msg| - %div= msg - - .note_text_and_preview.js-toggler-container - %a.js-note-preview-button.js-toggler-target.turn-on{ href: "javascript:;", data: {title: "Preview", url: preview_project_notes_path(@project)} } - %i.icon-eye-open - %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Edit"} } - %i.icon-edit - - = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' - .note_preview.js-note-preview.turn-off - - .buttons - = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" - %a.btn.grouped.js-close-discussion-note-form Cancel - .hint - .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. - .clearfix - - .note_options - .attachments.right - %h6.left Attachment: - %span.file_name File name... - - .input.input_file - %a.file_upload.btn.small Upload File - = f.file_field :attachment, class: "input-file" - %span.hint Any file less than 10 MB - - .notify_opts.right - %h6.left Notify via email: - = label_tag :notify do - = check_box_tag :notify, 1, !@note.for_commit? - %span Project team - - - if @note.notify_only_author?(current_user) - = label_tag :notify_author do - = check_box_tag :notify_author, 1 , !@note.for_commit? - %span Commit author - .clearfix 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 7ea8c4c..0000000 --- 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 3a6c3da..0000000 --- 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/_form.html.haml b/app/views/notes/_form.html.haml new file mode 100644 index 0000000..9d60044 --- /dev/null +++ b/app/views/notes/_form.html.haml @@ -0,0 +1,49 @@ += form_for [@project, @note], remote: true, html: { multipart: true, id: nil, class: "new_note js-new-note-form" } do |f| + + = note_target_fields + = f.hidden_field :line_code + = f.hidden_field :noteable_id + = f.hidden_field :noteable_type + + - if @note.errors.any? + .alert-message.block-message.error + - @note.errors.full_messages.each do |msg| + %div= msg + + .note_text_and_preview.js-toggler-container + %a.js-note-preview-button.js-toggler-target.turn-on{ href: "javascript:;", data: {title: "Preview", url: preview_project_notes_path(@project)} } + %i.icon-eye-open + %a.js-note-edit-button.js-toggler-target.turn-off{ href: "javascript:;", data: {title: "Edit"} } + %i.icon-edit + + = f.text_area :note, size: 255, class: 'note_text js-note-text js-gfm-input turn-on' + .note_preview.js-note-preview.turn-off + + .buttons + = f.submit 'Add Comment', class: "btn comment-btn grouped js-comment-button" + %a.btn.grouped.js-close-discussion-note-form Cancel + .hint + .right Comments are parsed with #{link_to "GitLab Flavored Markdown", help_markdown_path, target: '_blank'}. + .clearfix + + .note_options + .attachments.right + %h6.left Attachment: + %span.file_name File name... + + .input.input_file + %a.file_upload.btn.small Upload File + = f.file_field :attachment, class: "input-file" + %span.hint Any file less than 10 MB + + .notify_opts.right + %h6.left Notify via email: + = label_tag :notify do + = check_box_tag :notify, 1, !@note.for_commit? + %span Project team + + - if @note.notify_only_author?(current_user) + = label_tag :notify_author do + = check_box_tag :notify_author, 1 , !@note.for_commit? + %span Commit author + .clearfix diff --git a/app/views/notes/_notes_with_form.html.haml b/app/views/notes/_notes_with_form.html.haml index 2511cbe..2566edd 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 6a7f08f..bb583b8 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 03aec54..6ffb0cd 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 ae70dca..f082610 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(); -- libgit2 0.21.2