Fix handling form errors.

This commit is contained in:
Riyad Preukschas 2012-12-03 20:35:09 +01:00
parent c1ffee4e65
commit 7978f8dd2b
4 changed files with 68 additions and 21 deletions

View file

@ -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

View file

@ -0,0 +1,3 @@
.error_message.js-errors
- note.errors.full_messages.each do |msg|
%div= msg

View file

@ -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}");