[PATCH conductor] error messages in flash hud

jtomasek at redhat.com jtomasek at redhat.com
Fri Dec 16 14:05:51 UTC 2011


From: Jiri Tomasek <jtomasek at redhat.com>

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=743565
---
 src/app/views/layouts/_error_messages.html.haml   |   14 ++-
 src/app/views/layouts/_new_notification.html.haml |  118 +++++++++++----------
 src/app/views/layouts/application.html.haml       |    2 +-
 3 files changed, 72 insertions(+), 62 deletions(-)

diff --git a/src/app/views/layouts/_error_messages.html.haml b/src/app/views/layouts/_error_messages.html.haml
index 612861b..39d9720 100644
--- a/src/app/views/layouts/_error_messages.html.haml
+++ b/src/app/views/layouts/_error_messages.html.haml
@@ -1,4 +1,10 @@
-= pluralize(object.errors.count, "error") + " prohibited this record from being saved:"
-%ul
-- object.errors.full_messages.each do |msg|
-  %li= msg
\ No newline at end of file
+- content_for :error_messages do
+  .error.flash-group
+    .flash-subset
+      %div.heading
+        =image_tag 'flash_warning_icon.png', :alt => 'Errors'
+      %ul.flashes
+        %li
+          %strong= pluralize(object.errors.count, "error") + " prohibited this record from being saved:"
+        - object.errors.full_messages.each do |msg|
+          %li= msg
diff --git a/src/app/views/layouts/_new_notification.html.haml b/src/app/views/layouts/_new_notification.html.haml
index e248684..8ae73b0 100644
--- a/src/app/views/layouts/_new_notification.html.haml
+++ b/src/app/views/layouts/_new_notification.html.haml
@@ -1,69 +1,73 @@
 #flash-hud
   = link_to "Close","#", :class => "control"
-  -if flash[:success]
-    .notice.flash-group
-      .flash-subset
-        %div.heading
-          =image_tag 'flash_notice_icon.png', :alt => 'Notices'
-        %ul.flashes
-          %li= flash[:success]
-
-  -if flash[:notice]
-    .notice.flash-group
-      .flash-subset
-        %div.heading
-          =image_tag 'flash_notice_icon.png', :alt => 'Notices'
-        %ul.flashes
-          -if flash[:notice].kind_of?(Array)
-            -flash[:notice].each do |msg|
-              %li= msg
-          -else flash[:notice]
-            %li= flash[:notice]
-
-  -if flash[:warning]
-    .warning.flash-group
-      .flash-subset
-        %div.heading
-          =image_tag 'flash_warning_icon.png', :alt => 'Warnings'
-        %ul.flashes
-          %li= flash[:warning]
+  - unless flash.empty?
+    -if flash[:success]
+      .notice.flash-group
+        .flash-subset
+          %div.heading
+            =image_tag 'flash_notice_icon.png', :alt => 'Notices'
+          %ul.flashes
+            %li= flash[:success]
 
-  -if flash[:error]
-    -if flash[:error].kind_of?(String)
-      .flash-subset
-        %div.heading
-          =image_tag 'flash_error_icon.png', :alt => 'Errors'
-        =flash[:error]
-    -elsif flash[:error].kind_of?(Hash)
-      -unless flash[:error][:successes].blank?
-        .notice.flash-group
-          .flash-subset
-            %div.heading
-              =image_tag 'flash_notice_icon.png', :alt => 'Notices'
-            %ul.flashes
-              - flash[:error][:successes].each do |k, v|
-                %li= "#{k}: #{v}"
-      .error.flash-group
+    -if flash[:notice]
+      .notice.flash-group
         .flash-subset
           %div.heading
-            =image_tag 'flash_warning_icon.png', :alt => 'Warnings'
+            =image_tag 'flash_notice_icon.png', :alt => 'Notices'
           %ul.flashes
-            %li= flash[:error][:summary]
+            -if flash[:notice].kind_of?(Array)
+              -flash[:notice].each do |msg|
+                %li= msg
+            -else flash[:notice]
+              %li= flash[:notice]
+
+    -if flash[:warning]
+      .warning.flash-group
         .flash-subset
           %div.heading
-            =image_tag 'flash_error_icon.png', :alt => 'Errors'
+            =image_tag 'flash_warning_icon.png', :alt => 'Warnings'
           %ul.flashes
-            -if !flash[:error][:failures].blank?
-              -flash[:error][:failures].each do |k, v|
-                %li= [k, ': ', v]
-            -else
-              -flash[:error].each do |e|
-                %li= e
-    -elsif flash[:error].kind_of?(Array)
-      .error.flash-group
+            %li= flash[:warning]
+
+    -if flash[:error]
+      -if flash[:error].kind_of?(String)
         .flash-subset
           %div.heading
             =image_tag 'flash_error_icon.png', :alt => 'Errors'
-          %ul.flashes
-            -flash[:error].each do |msg|
-              %li= msg
+          =flash[:error]
+      -elsif flash[:error].kind_of?(Hash)
+        -unless flash[:error][:successes].blank?
+          .notice.flash-group
+            .flash-subset
+              %div.heading
+                =image_tag 'flash_notice_icon.png', :alt => 'Notices'
+              %ul.flashes
+                - flash[:error][:successes].each do |k, v|
+                  %li= "#{k}: #{v}"
+        .error.flash-group
+          .flash-subset
+            %div.heading
+              =image_tag 'flash_warning_icon.png', :alt => 'Warnings'
+            %ul.flashes
+              %li= flash[:error][:summary]
+          .flash-subset
+            %div.heading
+              =image_tag 'flash_error_icon.png', :alt => 'Errors'
+            %ul.flashes
+              -if !flash[:error][:failures].blank?
+                -flash[:error][:failures].each do |k, v|
+                  %li= [k, ': ', v]
+              -else
+                -flash[:error].each do |e|
+                  %li= e
+      -elsif flash[:error].kind_of?(Array)
+        .error.flash-group
+          .flash-subset
+            %div.heading
+              =image_tag 'flash_error_icon.png', :alt => 'Errors'
+            %ul.flashes
+              -flash[:error].each do |msg|
+                %li= msg
+
+  - if content_for? :error_messages
+    = yield :error_messages
diff --git a/src/app/views/layouts/application.html.haml b/src/app/views/layouts/application.html.haml
index d03c587..1d22b28 100644
--- a/src/app/views/layouts/application.html.haml
+++ b/src/app/views/layouts/application.html.haml
@@ -43,7 +43,7 @@
       %header#masthead
         = render :partial => 'layouts/masthead'
 
-      = render :partial => '/layouts/new_notification' unless flash.empty?
+      = render :partial => '/layouts/new_notification' if flash.present? or content_for?(:error_messages)
 
       %nav#primary
         =render_navigation :level => 1
-- 
1.7.7.3




More information about the aeolus-devel mailing list