From c93bd405154254d1bae40f21ac7b55cda732febc Mon Sep 17 00:00:00 2001 From: lukemelia Date: Fri, 8 Jun 2007 04:17:37 +0000 Subject: [PATCH] Improve the presentation of the error messages when attempting to create a new action with invalid data. Thanks to James Kebinger for his patch. Fixes #522. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@553 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/views/shared/_add_new_item_form.rhtml | 2 +- tracks/app/views/todos/_edit_form.rhtml | 2 +- tracks/app/views/todos/create.rjs | 2 +- tracks/app/views/todos/toggle_check.rjs | 2 +- tracks/public/stylesheets/standard.css | 5 ++++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tracks/app/views/shared/_add_new_item_form.rhtml b/tracks/app/views/shared/_add_new_item_form.rhtml index a59ea796..f524fa65 100644 --- a/tracks/app/views/shared/_add_new_item_form.rhtml +++ b/tracks/app/views/shared/_add_new_item_form.rhtml @@ -25,7 +25,7 @@ :url => todos_path, :method => :post, :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form' }) do -%> -
<%= error_messages_for("item") %>
+
<%= error_messages_for("item", :object_name => 'action') %>
<%= text_field( "todo", "description", "size" => 30, "tabindex" => 1) %> diff --git a/tracks/app/views/todos/_edit_form.rhtml b/tracks/app/views/todos/_edit_form.rhtml index ff6e7e70..38f35f3f 100644 --- a/tracks/app/views/todos/_edit_form.rhtml +++ b/tracks/app/views/todos/_edit_form.rhtml @@ -1,4 +1,4 @@ -
<%= error_messages_for("todo") %>
+
<%= error_messages_for("todo", :object_name => 'action') %>
<%= hidden_field( "todo", "id" ) %> <%= source_view_tag( @source_view ) %> diff --git a/tracks/app/views/todos/create.rjs b/tracks/app/views/todos/create.rjs index 33704f61..c12e0f96 100644 --- a/tracks/app/views/todos/create.rjs +++ b/tracks/app/views/todos/create.rjs @@ -21,5 +21,5 @@ if @saved end else page.show 'status' - page.replace_html 'status', "#{error_messages_for('todo')}" + page.replace_html 'status', "#{error_messages_for('todo', :object_name => 'action')}" end diff --git a/tracks/app/views/todos/toggle_check.rjs b/tracks/app/views/todos/toggle_check.rjs index 98bb8ed5..de6ab123 100644 --- a/tracks/app/views/todos/toggle_check.rjs +++ b/tracks/app/views/todos/toggle_check.rjs @@ -25,5 +25,5 @@ if @saved page.redirect_to project_path(@todo.project_id) end else - page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation") + page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this action from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation") end \ No newline at end of file diff --git a/tracks/public/stylesheets/standard.css b/tracks/public/stylesheets/standard.css index 35e3e032..66950c05 100644 --- a/tracks/public/stylesheets/standard.css +++ b/tracks/public/stylesheets/standard.css @@ -794,8 +794,9 @@ div.message { color: #fff; } -#errorExplanation p { +#errorExplanation > p { color: #333; + margin-top: 5px; margin-bottom: 0; padding: 5px; } @@ -804,6 +805,8 @@ div.message { font-size: 1em; list-style-type: disc; list-style-position: inside; + margin-left:7px; + color: #333; } ul#prefs {list-style-type: disc; margin-left: 15px;}