From 70d4c6080301d03d4d6d346a0d7fbe234cde5237 Mon Sep 17 00:00:00 2001 From: Gabriela Navarro Date: Mon, 3 Nov 2014 18:52:32 +0000 Subject: [PATCH] Moving position of fields on institution creation and add corporate_name field --- db/migrate/20141103183013_add_corporate_name_to_institution.rb | 9 +++++++++ lib/institution.rb | 4 +++- public/mpog-institution-validations.js | 3 ++- test/functional/mpog_software_plugin_controller_test.rb | 4 +++- views/mpog_software_plugin/_institution.html.erb | 57 ++++++++++++++++++++++++++++++++++----------------------- 5 files changed, 51 insertions(+), 26 deletions(-) create mode 100644 db/migrate/20141103183013_add_corporate_name_to_institution.rb diff --git a/db/migrate/20141103183013_add_corporate_name_to_institution.rb b/db/migrate/20141103183013_add_corporate_name_to_institution.rb new file mode 100644 index 0000000..69d4a19 --- /dev/null +++ b/db/migrate/20141103183013_add_corporate_name_to_institution.rb @@ -0,0 +1,9 @@ +class AddCorporateNameToInstitution < ActiveRecord::Migration + def up + add_column :institutions, :corporate_name, :string + end + + def down + remove_column :institutions, :corporate_name + end +end diff --git a/lib/institution.rb b/lib/institution.rb index 0176b6c..fc58208 100644 --- a/lib/institution.rb +++ b/lib/institution.rb @@ -8,10 +8,12 @@ class Institution < ActiveRecord::Base attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, :sub_juridical_nature, :normalization_level, :version, :cnpj, :type, :governmental_power, :governmental_sphere, - :sisp, :juridical_nature + :sisp, :juridical_nature, :corporate_name validates :name, :presence=>true, :uniqueness=>true + validates :corporate_name, :presence => true + before_save :verify_institution_type belongs_to :community diff --git a/public/mpog-institution-validations.js b/public/mpog-institution-validations.js index 33fe7f6..8544df0 100644 --- a/public/mpog-institution-validations.js +++ b/public/mpog-institution-validations.js @@ -46,7 +46,8 @@ acronym : jQuery("#institutions_acronym").val(), governmental_power: jQuery("#institutions_governmental_power").selected().val(), governmental_sphere: jQuery("#institutions_governmental_sphere").selected().val(), - juridical_nature: jQuery("#institutions_juridical_nature").selected().val() + juridical_nature: jQuery("#institutions_juridical_nature").selected().val(), + corporate_name: jQuery("#institutions_corporate_name").val() }, } } diff --git a/test/functional/mpog_software_plugin_controller_test.rb b/test/functional/mpog_software_plugin_controller_test.rb index a43162b..511bb2b 100644 --- a/test/functional/mpog_software_plugin_controller_test.rb +++ b/test/functional/mpog_software_plugin_controller_test.rb @@ -164,7 +164,8 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase :acronym => "", :governmental_power => "", :governmental_sphere => "", - :juridical_nature => "" + :juridical_nature => "", + :corporate_name => "coporate default" } } fields @@ -186,6 +187,7 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase institution.governmental_power = gov_p institution.governmental_sphere = gov_s institution.cnpj = cnpj + institution.corporate_name = "corporate default" institution.save! institution end diff --git a/views/mpog_software_plugin/_institution.html.erb b/views/mpog_software_plugin/_institution.html.erb index 1596f16..fc6d475 100644 --- a/views/mpog_software_plugin/_institution.html.erb +++ b/views/mpog_software_plugin/_institution.html.erb @@ -20,33 +20,45 @@
+
+ <%= _("All fields with (*) are mandatory") %> +
+
<%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %> - <%= required f.text_field(:name) %> - <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> - - <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> - <%= required f.text_field(:state) %> - <%= required f.text_field(:city) %> <%= fields_for :institutions do |inst| %> + +
+ + + +
+
+ + <%= required f.text_field(:name) %> + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
- <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %> + <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %> + <%= required inst.text_field(:corporate_name) %>
- -
- - - + <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> + <%= required f.text_field(:state) %> + <%= required f.text_field(:city) %> + + + +
+ <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> + <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %>
@@ -61,18 +73,17 @@
- <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> - <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%> + <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> + <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%>
- <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> - <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%> + <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> + <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%>
-
<%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> -- libgit2 0.21.2