Fix handling form errors.
This commit is contained in:
parent
c1ffee4e65
commit
7978f8dd2b
4 changed files with 68 additions and 21 deletions
|
@ -5,11 +5,6 @@
|
|||
= 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
|
||||
|
|
3
app/views/notes/_form_errors.html.haml
Normal file
3
app/views/notes/_form_errors.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
.error_message.js-errors
|
||||
- note.errors.full_messages.each do |msg|
|
||||
%div= msg
|
|
@ -7,10 +7,15 @@
|
|||
- 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);
|
||||
:plain
|
||||
var firstDiscussionNoteHtml = "#{escape_javascript(render "notes/diff_notes_with_reply", notes: [@note])}";
|
||||
NoteList.appendNewDiscussionNote("#{@note.discussion_id}",
|
||||
firstDiscussionNoteHtml,
|
||||
noteHtml);
|
||||
|
||||
- else
|
||||
-# TODO: insert form correctly
|
||||
$(".js-main-target-note").replaceWith("#{escape_javascript(render 'notes/common_form')}");
|
||||
GitLab.GfmAutoComplete.setup();
|
||||
var errorsHtml = "#{escape_javascript(render 'notes/form_errors', note: @note)}";
|
||||
- if note_for_main_target?(@note)
|
||||
NoteList.errorsOnForm(errorsHtml);
|
||||
- else
|
||||
NoteList.errorsOnForm(errorsHtml, "#{@note.discussion_id}");
|
Loading…
Add table
Add a link
Reference in a new issue