From: Jozef Zigmund <jzigmund(a)redhat.com>
---
src/app/helpers/application_helper.rb | 9 ---------
src/app/views/catalog_entries/_form.haml | 3 ++-
src/app/views/catalogs/_form.haml | 3 ++-
src/app/views/deployments/_edit.haml | 3 ++-
src/app/views/deployments/_launch_new.haml | 3 ++-
src/app/views/deployments/_new.haml | 3 ++-
src/app/views/hardware_profiles/_form.haml | 3 ++-
src/app/views/instances/_edit.haml | 3 ++-
src/app/views/layouts/_error_messages.haml | 4 ++++
src/app/views/permissions/new.haml | 3 ++-
src/app/views/pool_families/_form.haml | 3 ++-
src/app/views/pools/_form.haml | 3 ++-
src/app/views/provider_accounts/_form.haml | 3 ++-
src/app/views/realm_mappings/new.haml | 4 +++-
src/app/views/realms/_form.haml | 3 ++-
src/app/views/roles/_form.haml | 3 ++-
src/app/views/settings/self_service.haml | 3 ++-
src/app/views/users/_form.haml | 3 ++-
18 files changed, 37 insertions(+), 25 deletions(-)
create mode 100644 src/app/views/layouts/_error_messages.haml
diff --git a/src/app/helpers/application_helper.rb b/src/app/helpers/application_helper.rb
index c3cf0cc..06570ee 100644
--- a/src/app/helpers/application_helper.rb
+++ b/src/app/helpers/application_helper.rb
@@ -257,14 +257,5 @@ module ApplicationHelper
session[:javascript_enabled]
end
- def error_messages_for(obj)
- return unless obj and obj.errors.present?
- flash[:error] ||= ""
- obj.errors.each_pair do |attr, error|
- #TODO - Need to format this in some sensible way... <ul>?
- flash[:error] << "#{attr.to_s.humanize} #{error}"
- end
- end
-
module_function :count_uptime
end
diff --git a/src/app/views/catalog_entries/_form.haml b/src/app/views/catalog_entries/_form.haml
index 66c5e1a..c93c9b6 100644
--- a/src/app/views/catalog_entries/_form.haml
+++ b/src/app/views/catalog_entries/_form.haml
@@ -1,4 +1,5 @@
-= error_messages_for @catalog_entry
+- if @catalog_entry.errors.any?
+ = render 'layouts/error_messages', :object => @catalog_entry
%fieldset
%p
= form.label :name
diff --git a/src/app/views/catalogs/_form.haml b/src/app/views/catalogs/_form.haml
index 9a46e0c..db0fdcf 100644
--- a/src/app/views/catalogs/_form.haml
+++ b/src/app/views/catalogs/_form.haml
@@ -1,4 +1,5 @@
-= error_messages_for @catalog
+- if @catalog.errors.any?
+ = render 'layouts/error_messages', :object => @catalog
%fieldset
%p
= form.label :name
diff --git a/src/app/views/deployments/_edit.haml b/src/app/views/deployments/_edit.haml
index ba11a05..9aa7fe1 100644
--- a/src/app/views/deployments/_edit.haml
+++ b/src/app/views/deployments/_edit.haml
@@ -1,4 +1,5 @@
-= error_messages_for @deployment
+- if @deployment.errors.any?
+ = render 'layouts/error_messages', :object => @deployment
%h2 Edit deployment
= form_for @deployment do
%ul
diff --git a/src/app/views/deployments/_launch_new.haml b/src/app/views/deployments/_launch_new.haml
index 417ec99..d4c915e 100644
--- a/src/app/views/deployments/_launch_new.haml
+++ b/src/app/views/deployments/_launch_new.haml
@@ -15,7 +15,8 @@
.content
= form_for :deployment, {:url => new_deployment_path, :method => :get, :html => {:class => 'generic'}} do
- = error_messages_for @deployment
+ - if @deployment.errors.any?
+ = render 'layouts/error_messages', :object => @deployment
= hidden_field :deployment, :pool_id
%fieldset
%p
diff --git a/src/app/views/deployments/_new.haml b/src/app/views/deployments/_new.haml
index 7e7a930..9c36365 100644
--- a/src/app/views/deployments/_new.haml
+++ b/src/app/views/deployments/_new.haml
@@ -1,4 +1,5 @@
-= error_messages_for @deployment
+- if @deployment.errors.any?
+ = render 'layouts/error_messages', :object => @deployment
%header.page-header
%h1{:class => controller.controller_name}
Deployment
diff --git a/src/app/views/hardware_profiles/_form.haml b/src/app/views/hardware_profiles/_form.haml
index 8326038..8173f82 100644
--- a/src/app/views/hardware_profiles/_form.haml
+++ b/src/app/views/hardware_profiles/_form.haml
@@ -1,4 +1,5 @@
-= error_messages_for @hardware_profile
+- if @hardware_profile.errors.any?
+ = render 'layouts/error_messages', :object => @hardware_profile
= hwp_form.label :name
= hwp_form.text_field :name
%table
diff --git a/src/app/views/instances/_edit.haml b/src/app/views/instances/_edit.haml
index 475b528..f94551e 100644
--- a/src/app/views/instances/_edit.haml
+++ b/src/app/views/instances/_edit.haml
@@ -1,4 +1,5 @@
-= error_messages_for @instance
+- if @instance.errors.any?
+ = render 'layouts/error_messages', :object => @instance
%h2 Edit instance
= form_for @instance do
%ul
diff --git a/src/app/views/layouts/_error_messages.haml b/src/app/views/layouts/_error_messages.haml
new file mode 100644
index 0000000..612861b
--- /dev/null
+++ b/src/app/views/layouts/_error_messages.haml
@@ -0,0 +1,4 @@
+= 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
diff --git a/src/app/views/permissions/new.haml b/src/app/views/permissions/new.haml
index 08f3295..25bae8e 100644
--- a/src/app/views/permissions/new.haml
+++ b/src/app/views/permissions/new.haml
@@ -1,5 +1,6 @@
.conductor_form
- = error_messages_for @permission
+ - if @permission.errors.any?
+ = render 'layouts/error_messages', :object => @permission
%h2
Add new Permission for #{(a)permission_object.name}
%br/
diff --git a/src/app/views/pool_families/_form.haml b/src/app/views/pool_families/_form.haml
index 7dde46a..faae226 100644
--- a/src/app/views/pool_families/_form.haml
+++ b/src/app/views/pool_families/_form.haml
@@ -1,4 +1,5 @@
-= error_messages_for @pool_family
+- if @pool_family.errors.any?
+ = render 'layouts/error_messages', :object => @pool_family
%fieldset
%p
= form.label :name,'Pool Family Name'
diff --git a/src/app/views/pools/_form.haml b/src/app/views/pools/_form.haml
index 50e91fa..9ab7804 100644
--- a/src/app/views/pools/_form.haml
+++ b/src/app/views/pools/_form.haml
@@ -1,5 +1,6 @@
= form_for @pool, :html => {:class => 'generic'} do |form|
- = error_messages_for @pool
+ - if @pool.errors.any?
+ = render 'layouts/error_messages', :object => @pool
%fieldset
%p
diff --git a/src/app/views/provider_accounts/_form.haml b/src/app/views/provider_accounts/_form.haml
index 0388616..ef5e181 100644
--- a/src/app/views/provider_accounts/_form.haml
+++ b/src/app/views/provider_accounts/_form.haml
@@ -1,4 +1,5 @@
-= error_messages_for @provider_account
+- if @provider_account.errors.any?
+ = render 'layouts/error_messages', :object => @provider_account
= render :partial => 'provider_selection'
%fieldset.options
= form.submit 'Save', :class => "button"
diff --git a/src/app/views/realm_mappings/new.haml b/src/app/views/realm_mappings/new.haml
index 9e2772b..232f7a2 100644
--- a/src/app/views/realm_mappings/new.haml
+++ b/src/app/views/realm_mappings/new.haml
@@ -1,7 +1,9 @@
= render :partial => 'layouts/admin_header'
%div#view
-= error_messages_for @realm_target
+- if @realm_target.errors.any?
+ = render 'layouts/error_messages', :object => @realm_target
+
%h2 Create a new Realm Mapping
= form_for @realm_target, :url => realm_mappings_path do |f|
= f.hidden_field :frontend_realm_id
diff --git a/src/app/views/realms/_form.haml b/src/app/views/realms/_form.haml
index 42d879d..1a79296 100644
--- a/src/app/views/realms/_form.haml
+++ b/src/app/views/realms/_form.haml
@@ -1,4 +1,5 @@
-- error_messages_for @realm
+- if @realm.errors.any?
+ = render 'layouts/error_messages', :object => @realm
%fieldset
= form.label :name, 'Realm Name'
= form.text_field :name, :title => 'realm_name', :value => @realm.name, :class => 'em long'
diff --git a/src/app/views/roles/_form.haml b/src/app/views/roles/_form.haml
index a3192a7..ffcd1b9 100644
--- a/src/app/views/roles/_form.haml
+++ b/src/app/views/roles/_form.haml
@@ -1,4 +1,5 @@
-- error_messages_for @role
+- if @role.errors.any?
+ = render 'layouts/error_messages', :object => @role
%fieldset
= form.label :name, 'Name'
= form.text_field :name, :class => "em long"
diff --git a/src/app/views/settings/self_service.haml b/src/app/views/settings/self_service.haml
index acabed0..bb4d1fc 100644
--- a/src/app/views/settings/self_service.haml
+++ b/src/app/views/settings/self_service.haml
@@ -53,7 +53,8 @@
= t('.quota') + ":"
= text_field :self_service_default_quota, :maximum_running_instances, :class => 'grid_5'
.grid_2.la (instances)
- = error_messages_for @self_service_default_quota if @self_service_default_quota
+ - if @self_service_default_quota.errors.any?
+ = render 'layouts/error_messages', :object => @self_service_default_quota
-#%h3 POOLS
-#%fieldset.clearfix
%label.grid_2.alpha Permissions:
diff --git a/src/app/views/users/_form.haml b/src/app/views/users/_form.haml
index 5e56d73..0a41f27 100644
--- a/src/app/views/users/_form.haml
+++ b/src/app/views/users/_form.haml
@@ -1,4 +1,5 @@
-- error_messages_for @user
+- if @user.errors.any?
+ = render 'layouts/error_messages', :object => @user
%fieldset
%p
--
1.7.6.2