diff --git a/controllers/gov_user_plugin_controller.rb b/controllers/gov_user_plugin_controller.rb
index b177c9d..cecddaa 100644
--- a/controllers/gov_user_plugin_controller.rb
+++ b/controllers/gov_user_plugin_controller.rb
@@ -16,6 +16,14 @@ class GovUserPluginController < ApplicationController
@show_sisp_field = environment.admins.include?(current_user.person)
@state_list = get_state_list()
+ params[:community] ||= {}
+ params[:institutions] ||= {}
+
+ @state_options = [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]}
+ @governmental_sphere_options = [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}
+ @governmental_power_options = [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}
+ @juridical_nature_options = [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}
+
if request.xhr?
render :layout=>false
else
@@ -35,6 +43,14 @@ class GovUserPluginController < ApplicationController
@state_list = get_state_list()
@url_token = split_http_referer request.original_url()
+
+ params[:community] ||= {}
+ params[:institutions] ||= {}
+
+ @state_options = [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]}
+ @governmental_sphere_options = [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}
+ @governmental_power_options = [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}
+ @juridical_nature_options = [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}
end
def new_institution
@@ -45,10 +61,10 @@ class GovUserPluginController < ApplicationController
institution_template = Community["institution"]
add_template_in_params institution_template
- institution = private_create_institution
- add_environment_admins_to_institution institution
+ @institutions = private_create_institution
+ add_environment_admins_to_institution @institutions
- response_message = save_institution institution
+ response_message = save_institution @institutions
if request.xhr? #User create institution
render :json => response_message.to_json
@@ -203,7 +219,7 @@ class GovUserPluginController < ApplicationController
redirect_to :controller => "/admin_panel", :action => "index"
else
flash[:errors] = response_message[:errors]
- render :controller => "gov_user_plugin", :action => "create_institution_admin"
+ redirect_to :controller => "gov_user_plugin", :action => "create_institution_admin", :params => params
end
end
diff --git a/public/views/create-institution.js b/public/views/create-institution.js
index 5349e4c..b40226c 100644
--- a/public/views/create-institution.js
+++ b/public/views/create-institution.js
@@ -102,8 +102,12 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement']
errors += "
"+response.errors[i]+"";
}
errors += "";
-
- $("#create_institution_errors").switchClass("hide-field", "show-field").html(""+response.message+"
"+errors);
+ if($('#institution_dialog') != []){
+ $('#create_institution_errors').switchClass("show-field", "hide-field");
+ $('#errorExplanation').html(""+response.message+"
"+errors);
+ }else{
+ $("#create_institution_errors").switchClass("hide-field", "show-field").html(""+response.message+"
"+errors);
+ }
}
}
diff --git a/views/gov_user_plugin/_institution.html.erb b/views/gov_user_plugin/_institution.html.erb
index 6aee575..09e8ae7 100644
--- a/views/gov_user_plugin/_institution.html.erb
+++ b/views/gov_user_plugin/_institution.html.erb
@@ -20,11 +20,11 @@
-
- <%= _("All fields with (*) are mandatory") %>
-
-
<%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %>
+
+ <%= required_fields_message %>
+
+
<%= hidden_field_tag "edit_institution_page", false %>
<%= fields_for :institutions do |inst| %>
@@ -40,22 +40,24 @@
- <%= required f.text_field(:name) %>
+ <%= required f.text_field(:name, :value => params[:community][:name]) %>
<%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
-
-
- <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %>
- <%= required inst.text_field(:corporate_name) %>
-
-
+ >
+
+
+ <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %>
+ <%= required inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name]) %>
+
+
+
<%= hidden_field_tag "acronym_translate", _("Acronym") %>
<%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
<%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %>
- <%= inst.text_field(:acronym) %>
+ <%= inst.text_field(:acronym, :value => params[:institutions][:acronym]) %>
@@ -64,37 +66,37 @@
- <%= f.select(:state, [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]}) %>
+ <%= f.select(:state, @state_options, :selected => params[:community][:state]) %>
- <%= required f.text_field(:city, :id => "city_field") %>
+ <%= required f.text_field(:city, :value => params[:community][:city], :id => "city_field") %>
<%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
- <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %>
+ <%= required inst.text_field(:cnpj, :value => params[:institutions][:cnpj], :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %>
<%= 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.select(:governmental_sphere, @governmental_sphere_options, :selected => params[:institutions][:governmental_sphere])%>
<%= 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.select(:governmental_power, @governmental_power_options, :selected => params[:institutions][:governmental_power])%>
<%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %>
- <%= inst.select(:juridical_nature, [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}, {:selected=>0})%>
+ <%= inst.select(:juridical_nature, @juridical_nature_options, :selected => params[:institutions][:juridical_nature])%>
--
libgit2 0.21.2