From 73fecc61555d3fba891c88cb0818e70f6007513b Mon Sep 17 00:00:00 2001 From: Luciano Prestes Cavalcanti Date: Tue, 10 Mar 2015 11:53:08 -0300 Subject: [PATCH] Highlight fields with error after validation in software create --- controllers/software_communities_plugin_myprofile_controller.rb | 15 +++++++++++++++ public/style.css | 4 ++++ views/software_communities_plugin_myprofile/new_software.html.erb | 52 ++++++++++++++++++++++++++++++---------------------- 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/controllers/software_communities_plugin_myprofile_controller.rb b/controllers/software_communities_plugin_myprofile_controller.rb index 2aae091..b4a3124 100644 --- a/controllers/software_communities_plugin_myprofile_controller.rb +++ b/controllers/software_communities_plugin_myprofile_controller.rb @@ -27,6 +27,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController end control_software_creation + update_new_software_errors end def search_offerers @@ -217,4 +218,18 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController end end end + + def update_new_software_errors + if request.post? + @community.valid? + @software_info.valid? + @license_info.valid? + add_software_erros + end + + @error_community_name = @community.errors.include?(:name) ? "highlight-error" : "" + @error_software_domain = @software_info.errors.include?(:domain) ? "highlight-error" : "" + @error_software_finality = @software_info.errors.include?(:finality) ? "highlight-error" : "" + @error_software_license = @license_info.errors.include?(:version) ? "highlight-error" : "" + end end diff --git a/public/style.css b/public/style.css index 77e1ce4..88ee0ae 100644 --- a/public/style.css +++ b/public/style.css @@ -533,3 +533,7 @@ div#finality textarea { resize: none; height: 100px; } + +.highlight-error { + background-color: #FF0000; +} \ No newline at end of file diff --git a/views/software_communities_plugin_myprofile/new_software.html.erb b/views/software_communities_plugin_myprofile/new_software.html.erb index 5827de6..ca35dd1 100644 --- a/views/software_communities_plugin_myprofile/new_software.html.erb +++ b/views/software_communities_plugin_myprofile/new_software.html.erb @@ -33,25 +33,31 @@ <%= required_fields_message %> - <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %> - <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %> +
> + <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %> + <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %> +


- <%= label("domain", _('Domain'), {:class => "formlabel mandatory"}) %> -
+
> + <%= label("domain", _('Domain'), {:class => "formlabel mandatory"}) %> +
- <%= environment.default_hostname %>/ - <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %> + <%= environment.default_hostname %>/ + <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %> +
- <%= fields_for @software_info do |swf| %> -
- <%= swf.label("finality" ,_("Finality"), :class=>"formlabel mandatory") %> - <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %> -
- <% end %> +
> + <%= fields_for @software_info do |swf| %> +
+ <%= swf.label("finality" ,_("Finality"), :class=>"formlabel mandatory") %> + <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %> +
+ <% end %> +
-
- - <%= render :partial => "license_info_fields", :locals => { - :license_version => "", - :license_id => "", - :another_version=>"", - :another_link=>"" - } %> +
> +
+ + <%= render :partial => "license_info_fields", :locals => { + :license_version => "", + :license_id => "", + :another_version=>"", + :another_link=>"" + } %> +
<%= fields_for @software_info do |swf| %> -- libgit2 0.21.2