Commit 70d4c6080301d03d4d6d346a0d7fbe234cde5237
1 parent
d2acf743
Exists in
master
and in
5 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,10 +8,12 @@ class Institution < ActiveRecord::Base | ||
8 | attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, | 8 | attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, |
9 | :sub_juridical_nature, :normalization_level, | 9 | :sub_juridical_nature, :normalization_level, |
10 | :version, :cnpj, :type, :governmental_power, :governmental_sphere, | 10 | :version, :cnpj, :type, :governmental_power, :governmental_sphere, |
11 | - :sisp, :juridical_nature | 11 | + :sisp, :juridical_nature, :corporate_name |
12 | 12 | ||
13 | validates :name, :presence=>true, :uniqueness=>true | 13 | validates :name, :presence=>true, :uniqueness=>true |
14 | 14 | ||
15 | + validates :corporate_name, :presence => true | ||
16 | + | ||
15 | before_save :verify_institution_type | 17 | before_save :verify_institution_type |
16 | 18 | ||
17 | belongs_to :community | 19 | belongs_to :community |
public/mpog-institution-validations.js
@@ -46,7 +46,8 @@ | @@ -46,7 +46,8 @@ | ||
46 | acronym : jQuery("#institutions_acronym").val(), | 46 | acronym : jQuery("#institutions_acronym").val(), |
47 | governmental_power: jQuery("#institutions_governmental_power").selected().val(), | 47 | governmental_power: jQuery("#institutions_governmental_power").selected().val(), |
48 | governmental_sphere: jQuery("#institutions_governmental_sphere").selected().val(), | 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,7 +164,8 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
164 | :acronym => "", | 164 | :acronym => "", |
165 | :governmental_power => "", | 165 | :governmental_power => "", |
166 | :governmental_sphere => "", | 166 | :governmental_sphere => "", |
167 | - :juridical_nature => "" | 167 | + :juridical_nature => "", |
168 | + :corporate_name => "coporate default" | ||
168 | } | 169 | } |
169 | } | 170 | } |
170 | fields | 171 | fields |
@@ -186,6 +187,7 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | @@ -186,6 +187,7 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase | ||
186 | institution.governmental_power = gov_p | 187 | institution.governmental_power = gov_p |
187 | institution.governmental_sphere = gov_s | 188 | institution.governmental_sphere = gov_s |
188 | institution.cnpj = cnpj | 189 | institution.cnpj = cnpj |
190 | + institution.corporate_name = "corporate default" | ||
189 | institution.save! | 191 | institution.save! |
190 | institution | 192 | institution |
191 | end | 193 | end |
views/mpog_software_plugin/_institution.html.erb
@@ -20,33 +20,45 @@ | @@ -20,33 +20,45 @@ | ||
20 | <div id = 'create_institution_errors' class='errorExplanation hide-field'></div> | 20 | <div id = 'create_institution_errors' class='errorExplanation hide-field'></div> |
21 | 21 | ||
22 | <div> | 22 | <div> |
23 | + <div class="fields-required"> | ||
24 | + <span class="errorExplanation"><%= _("All fields with (*) are mandatory") %></span> | ||
25 | + </div> | ||
26 | + <br/> | ||
23 | <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %> | 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 | <%= fields_for :institutions do |inst| %> | 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 | <span class='required-field'> | 46 | <span class='required-field'> |
34 | <div class="formfield type-text"> | 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 | </div> | 50 | </div> |
38 | </span> | 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 | </div> | 62 | </div> |
51 | </span> | 63 | </span> |
52 | 64 | ||
@@ -61,18 +73,17 @@ | @@ -61,18 +73,17 @@ | ||
61 | 73 | ||
62 | <span class='required-field public-institutions-fields'> | 74 | <span class='required-field public-institutions-fields'> |
63 | <div class="formfield type-text"> | 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 | </div> | 78 | </div> |
67 | </span> | 79 | </span> |
68 | 80 | ||
69 | <span class='required-field public-institutions-fields'> | 81 | <span class='required-field public-institutions-fields'> |
70 | <div class="formfield type-text"> | 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 | </div> | 85 | </div> |
74 | </span> | 86 | </span> |
75 | - | ||
76 | <span class='required-field public-institutions-fields'> | 87 | <span class='required-field public-institutions-fields'> |
77 | <div class="formfield type-text"> | 88 | <div class="formfield type-text"> |
78 | <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> | 89 | <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> |