diff --git a/controllers/mpog_software_plugin_controller.rb b/controllers/mpog_software_plugin_controller.rb index 655554c..f4fd137 100644 --- a/controllers/mpog_software_plugin_controller.rb +++ b/controllers/mpog_software_plugin_controller.rb @@ -40,6 +40,7 @@ class MpogSoftwarePluginController < ApplicationController def create_institution @show_sisp_field = environment.admins.include?(current_user.person) + @estate_list = get_state_list() if request.xhr? render :layout=>false @@ -57,6 +58,7 @@ class MpogSoftwarePluginController < ApplicationController def create_institution_admin @show_sisp_field = environment.admins.include?(current_user.person) + @estate_list = get_state_list() @url_token = split_http_referer request.original_url() end @@ -143,7 +145,7 @@ class MpogSoftwarePluginController < ApplicationController def get_brazil_states redirect_to "/" unless request.xhr? - state_list = NationalRegion.find(:all, :conditions=>["national_region_type_id = ?", 2], :order=>"name") + state_list = get_state_list() render :json=>state_list.collect {|state| state.name }.to_json end @@ -175,6 +177,10 @@ class MpogSoftwarePluginController < ApplicationController protected + def get_state_list + NationalRegion.find(:all, :conditions=>["national_region_type_id = ?", 2], :order=>"name") + end + def private_create_institution community = Community.new(params[:community]) community.environment = environment diff --git a/public/mpog-institution-validations.js b/public/mpog-institution-validations.js index 4b6b7bf..0b33f7e 100644 --- a/public/mpog-institution-validations.js +++ b/public/mpog-institution-validations.js @@ -4,6 +4,8 @@ jQuery.get("/plugin/mpog_software/create_institution", function(response){ jQuery("#institution_dialog").html(response); + + set_form_count_custom_data(); set_events(); jQuery("#institution_dialog").dialog({ @@ -212,10 +214,12 @@ var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); var default_option = SelectElement.generateOption("BR", "Brazil"); - jQuery('#community_country').find("option[value='']").remove(); - jQuery('#community_country').prepend(divisor_option); - jQuery('#community_country').prepend(default_option); - jQuery('#community_country').val("BR"); + if( jQuery('#community_country').find("option[value='']").length == 1 ) { + jQuery('#community_country').find("option[value='']").remove(); + jQuery('#community_country').prepend(divisor_option); + jQuery('#community_country').prepend(default_option); + jQuery('#community_country').val("BR"); + } } function set_events() { diff --git a/views/mpog_software_plugin/_institution.html.erb b/views/mpog_software_plugin/_institution.html.erb index 17be5bd..66010e4 100644 --- a/views/mpog_software_plugin/_institution.html.erb +++ b/views/mpog_software_plugin/_institution.html.erb @@ -51,7 +51,14 @@ <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> - <%= required f.text_field(:state) %> + + +
+ + <%= f.select(:state, @estate_list.collect {|state| [state.name, state.name]}) %> +
+
+ <%= required f.text_field(:city) %> -- libgit2 0.21.2