Commit 80db92cc2fef121689f6fa2caaed8a61dc3731de

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent 760ea10e
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

fix_institution: Change state to select field and correct country bug

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
controllers/mpog_software_plugin_controller.rb
@@ -40,6 +40,7 @@ class MpogSoftwarePluginController &lt; ApplicationController @@ -40,6 +40,7 @@ class MpogSoftwarePluginController &lt; ApplicationController
40 40
41 def create_institution 41 def create_institution
42 @show_sisp_field = environment.admins.include?(current_user.person) 42 @show_sisp_field = environment.admins.include?(current_user.person)
  43 + @estate_list = get_state_list()
43 44
44 if request.xhr? 45 if request.xhr?
45 render :layout=>false 46 render :layout=>false
@@ -57,6 +58,7 @@ class MpogSoftwarePluginController &lt; ApplicationController @@ -57,6 +58,7 @@ class MpogSoftwarePluginController &lt; ApplicationController
57 58
58 def create_institution_admin 59 def create_institution_admin
59 @show_sisp_field = environment.admins.include?(current_user.person) 60 @show_sisp_field = environment.admins.include?(current_user.person)
  61 + @estate_list = get_state_list()
60 62
61 @url_token = split_http_referer request.original_url() 63 @url_token = split_http_referer request.original_url()
62 end 64 end
@@ -143,7 +145,7 @@ class MpogSoftwarePluginController &lt; ApplicationController @@ -143,7 +145,7 @@ class MpogSoftwarePluginController &lt; ApplicationController
143 def get_brazil_states 145 def get_brazil_states
144 redirect_to "/" unless request.xhr? 146 redirect_to "/" unless request.xhr?
145 147
146 - state_list = NationalRegion.find(:all, :conditions=>["national_region_type_id = ?", 2], :order=>"name") 148 + state_list = get_state_list()
147 render :json=>state_list.collect {|state| state.name }.to_json 149 render :json=>state_list.collect {|state| state.name }.to_json
148 end 150 end
149 151
@@ -175,6 +177,10 @@ class MpogSoftwarePluginController &lt; ApplicationController @@ -175,6 +177,10 @@ class MpogSoftwarePluginController &lt; ApplicationController
175 177
176 protected 178 protected
177 179
  180 + def get_state_list
  181 + NationalRegion.find(:all, :conditions=>["national_region_type_id = ?", 2], :order=>"name")
  182 + end
  183 +
178 def private_create_institution 184 def private_create_institution
179 community = Community.new(params[:community]) 185 community = Community.new(params[:community])
180 community.environment = environment 186 community.environment = environment
public/mpog-institution-validations.js
@@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
4 4
5 jQuery.get("/plugin/mpog_software/create_institution", function(response){ 5 jQuery.get("/plugin/mpog_software/create_institution", function(response){
6 jQuery("#institution_dialog").html(response); 6 jQuery("#institution_dialog").html(response);
  7 +
  8 + set_form_count_custom_data();
7 set_events(); 9 set_events();
8 10
9 jQuery("#institution_dialog").dialog({ 11 jQuery("#institution_dialog").dialog({
@@ -212,10 +214,12 @@ @@ -212,10 +214,12 @@
212 var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); 214 var divisor_option = SelectElement.generateOption("-1", "--------------------------------");
213 var default_option = SelectElement.generateOption("BR", "Brazil"); 215 var default_option = SelectElement.generateOption("BR", "Brazil");
214 216
215 - jQuery('#community_country').find("option[value='']").remove();  
216 - jQuery('#community_country').prepend(divisor_option);  
217 - jQuery('#community_country').prepend(default_option);  
218 - jQuery('#community_country').val("BR"); 217 + if( jQuery('#community_country').find("option[value='']").length == 1 ) {
  218 + jQuery('#community_country').find("option[value='']").remove();
  219 + jQuery('#community_country').prepend(divisor_option);
  220 + jQuery('#community_country').prepend(default_option);
  221 + jQuery('#community_country').val("BR");
  222 + }
219 } 223 }
220 224
221 function set_events() { 225 function set_events() {
views/mpog_software_plugin/_institution.html.erb
@@ -51,7 +51,14 @@ @@ -51,7 +51,14 @@
51 </span> 51 </span>
52 52
53 <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %> 53 <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %>
54 - <%= required f.text_field(:state) %> 54 +
  55 + <span class='required-field'>
  56 + <div class="formfield">
  57 + <label for="community_state" class="formlabel"><%= _("State") %></label>
  58 + <%= f.select(:state, @estate_list.collect {|state| [state.name, state.name]}) %>
  59 + </div>
  60 + </span>
  61 +
55 <%= required f.text_field(:city) %> 62 <%= required f.text_field(:city) %>
56 63
57 64