Commit 70d4c6080301d03d4d6d346a0d7fbe234cde5237
1 parent
d2acf743
Exists in
master
and in
79 other branches
Moving position of fields on institution creation and add corporate_name
field Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
5 changed files
with
51 additions
and
26 deletions
Show diff stats
db/migrate/20141103183013_add_corporate_name_to_institution.rb
0 → 100644
lib/institution.rb
... | ... | @@ -8,10 +8,12 @@ class Institution < ActiveRecord::Base |
8 | 8 | attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, |
9 | 9 | :sub_juridical_nature, :normalization_level, |
10 | 10 | :version, :cnpj, :type, :governmental_power, :governmental_sphere, |
11 | - :sisp, :juridical_nature | |
11 | + :sisp, :juridical_nature, :corporate_name | |
12 | 12 | |
13 | 13 | validates :name, :presence=>true, :uniqueness=>true |
14 | 14 | |
15 | + validates :corporate_name, :presence => true | |
16 | + | |
15 | 17 | before_save :verify_institution_type |
16 | 18 | |
17 | 19 | belongs_to :community | ... | ... |
public/mpog-institution-validations.js
... | ... | @@ -46,7 +46,8 @@ |
46 | 46 | acronym : jQuery("#institutions_acronym").val(), |
47 | 47 | governmental_power: jQuery("#institutions_governmental_power").selected().val(), |
48 | 48 | governmental_sphere: jQuery("#institutions_governmental_sphere").selected().val(), |
49 | - juridical_nature: jQuery("#institutions_juridical_nature").selected().val() | |
49 | + juridical_nature: jQuery("#institutions_juridical_nature").selected().val(), | |
50 | + corporate_name: jQuery("#institutions_corporate_name").val() | |
50 | 51 | }, |
51 | 52 | } |
52 | 53 | } | ... | ... |
test/functional/mpog_software_plugin_controller_test.rb
... | ... | @@ -164,7 +164,8 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
164 | 164 | :acronym => "", |
165 | 165 | :governmental_power => "", |
166 | 166 | :governmental_sphere => "", |
167 | - :juridical_nature => "" | |
167 | + :juridical_nature => "", | |
168 | + :corporate_name => "coporate default" | |
168 | 169 | } |
169 | 170 | } |
170 | 171 | fields |
... | ... | @@ -186,6 +187,7 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
186 | 187 | institution.governmental_power = gov_p |
187 | 188 | institution.governmental_sphere = gov_s |
188 | 189 | institution.cnpj = cnpj |
190 | + institution.corporate_name = "corporate default" | |
189 | 191 | institution.save! |
190 | 192 | institution |
191 | 193 | end | ... | ... |
views/mpog_software_plugin/_institution.html.erb
... | ... | @@ -20,33 +20,45 @@ |
20 | 20 | <div id = 'create_institution_errors' class='errorExplanation hide-field'></div> |
21 | 21 | |
22 | 22 | <div> |
23 | + <div class="fields-required"> | |
24 | + <span class="errorExplanation"><%= _("All fields with (*) are mandatory") %></span> | |
25 | + </div> | |
26 | + <br/> | |
23 | 27 | <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %> |
24 | - <%= required f.text_field(:name) %> | |
25 | - <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> | |
26 | - | |
27 | - <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> | |
28 | - <%= required f.text_field(:state) %> | |
29 | - <%= required f.text_field(:city) %> | |
30 | 28 | |
31 | 29 | <%= fields_for :institutions do |inst| %> |
30 | + <span class=''> | |
31 | + <div class='formfield type-radio'> | |
32 | + <label> <%= _("Public Institution") %> | |
33 | + <%= radio_button_tag("institutions[type]", "PublicInstitution", true) %> | |
34 | + </label> | |
35 | + | |
36 | + <label> | |
37 | + <%= _("Private Institution") %> | |
38 | + <%= radio_button_tag("institutions[type]" ,"PrivateInstitution")%> | |
39 | + </label> | |
40 | + </div> | |
41 | + </span> | |
42 | + | |
43 | + <%= required f.text_field(:name) %> | |
44 | + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> | |
32 | 45 | |
33 | 46 | <span class='required-field'> |
34 | 47 | <div class="formfield type-text"> |
35 | - <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> | |
36 | - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %> | |
48 | + <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %> | |
49 | + <%= required inst.text_field(:corporate_name) %> | |
37 | 50 | </div> |
38 | 51 | </span> |
39 | 52 | |
40 | - <span class=''> | |
41 | - <div class='formfield type-radio'> | |
42 | - <label> <%= _("Public Institution") %> | |
43 | - <%= radio_button_tag("institutions[type]", "PublicInstitution", true) %> | |
44 | - </label> | |
45 | - | |
46 | - <label> | |
47 | - <%= _("Private Institution") %> | |
48 | - <%= radio_button_tag("institutions[type]" ,"PrivateInstitution")%> | |
49 | - </label> | |
53 | + <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> | |
54 | + <%= required f.text_field(:state) %> | |
55 | + <%= required f.text_field(:city) %> | |
56 | + | |
57 | + | |
58 | + <span class='required-field'> | |
59 | + <div class="formfield type-text"> | |
60 | + <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> | |
61 | + <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %> | |
50 | 62 | </div> |
51 | 63 | </span> |
52 | 64 | |
... | ... | @@ -61,18 +73,17 @@ |
61 | 73 | |
62 | 74 | <span class='required-field public-institutions-fields'> |
63 | 75 | <div class="formfield type-text"> |
64 | - <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> | |
65 | - <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%> | |
76 | + <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> | |
77 | + <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%> | |
66 | 78 | </div> |
67 | 79 | </span> |
68 | 80 | |
69 | 81 | <span class='required-field public-institutions-fields'> |
70 | 82 | <div class="formfield type-text"> |
71 | - <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> | |
72 | - <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%> | |
83 | + <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> | |
84 | + <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%> | |
73 | 85 | </div> |
74 | 86 | </span> |
75 | - | |
76 | 87 | <span class='required-field public-institutions-fields'> |
77 | 88 | <div class="formfield type-text"> |
78 | 89 | <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> | ... | ... |