Commit 73fecc61555d3fba891c88cb0818e70f6007513b

Authored by Luciano Prestes
1 parent 946f97e5

Highlight fields with error after validation in software create

Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
controllers/software_communities_plugin_myprofile_controller.rb
... ... @@ -27,6 +27,7 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
27 27 end
28 28  
29 29 control_software_creation
  30 + update_new_software_errors
30 31 end
31 32  
32 33 def search_offerers
... ... @@ -217,4 +218,18 @@ class SoftwareCommunitiesPluginMyprofileController &lt; MyProfileController
217 218 end
218 219 end
219 220 end
  221 +
  222 + def update_new_software_errors
  223 + if request.post?
  224 + @community.valid?
  225 + @software_info.valid?
  226 + @license_info.valid?
  227 + add_software_erros
  228 + end
  229 +
  230 + @error_community_name = @community.errors.include?(:name) ? "highlight-error" : ""
  231 + @error_software_domain = @software_info.errors.include?(:domain) ? "highlight-error" : ""
  232 + @error_software_finality = @software_info.errors.include?(:finality) ? "highlight-error" : ""
  233 + @error_software_license = @license_info.errors.include?(:version) ? "highlight-error" : ""
  234 + end
220 235 end
... ...
public/style.css
... ... @@ -533,3 +533,7 @@ div#finality textarea {
533 533 resize: none;
534 534 height: 100px;
535 535 }
  536 +
  537 +.highlight-error {
  538 + background-color: #FF0000;
  539 +}
536 540 \ No newline at end of file
... ...
views/software_communities_plugin_myprofile/new_software.html.erb
... ... @@ -33,25 +33,31 @@
33 33  
34 34 <%= required_fields_message %>
35 35  
36   - <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %>
37   - <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %>
  36 + <div class= <%= @error_community_name %> >
  37 + <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %>
  38 + <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %>
  39 + </div>
38 40  
39 41 <br>
40 42 <br>
41 43  
42   - <%= label("domain", _('Domain'), {:class => "formlabel mandatory"}) %>
43   - <div id='software-name-field' class='formfield'>
  44 + <div class= <%= @error_community_name %> >
  45 + <%= label("domain", _('Domain'), {:class => "formlabel mandatory"}) %>
  46 + <div id='software-name-field' class='formfield'>
44 47  
45   - <span id='software-hostname'><%= environment.default_hostname %>/</span>
46   - <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %>
  48 + <span id='software-hostname'><%= environment.default_hostname %>/</span>
  49 + <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %>
  50 + </div>
47 51 </div>
48 52  
49   - <%= fields_for @software_info do |swf| %>
50   - <div id="finality" class="formfield type-text">
51   - <%= swf.label("finality" ,_("Finality"), :class=>"formlabel mandatory") %>
52   - <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %>
53   - </div>
54   - <% end %>
  53 + <div class= <%= @error_software_finality %> >
  54 + <%= fields_for @software_info do |swf| %>
  55 + <div id="finality" class="formfield type-text">
  56 + <%= swf.label("finality" ,_("Finality"), :class=>"formlabel mandatory") %>
  57 + <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %>
  58 + </div>
  59 + <% end %>
  60 + </div>
55 61  
56 62 <div id="profile_change_picture_title" class="formlabel">
57 63 <label>
... ... @@ -64,16 +70,18 @@
64 70 <% end %>
65 71 </div>
66 72  
67   - <div id="profile_change_picture_title" class="formlabel formfieldline">
68   - <label class="formlabel mandatory">
69   - <%= _("License Version: ") %>
70   - </label>
71   - <%= render :partial => "license_info_fields", :locals => {
72   - :license_version => "",
73   - :license_id => "",
74   - :another_version=>"",
75   - :another_link=>""
76   - } %>
  73 + <div class= <%= @error_software_license %> >
  74 + <div id="profile_change_picture_title" class="formlabel formfieldline">
  75 + <label class="formlabel mandatory">
  76 + <%= _("License Version: ") %>
  77 + </label>
  78 + <%= render :partial => "license_info_fields", :locals => {
  79 + :license_version => "",
  80 + :license_id => "",
  81 + :another_version=>"",
  82 + :another_link=>""
  83 + } %>
  84 + </div>
77 85 </div>
78 86  
79 87 <%= fields_for @software_info do |swf| %>
... ...