Commit e682f9c198fec014bbdfbc9278722fbe620a39e3

Authored by Fabio Teixeira
Committed by Gabriela Navarro
1 parent d24e09be
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

Add Brazil as first country in the institution's select

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
lib/mpog_software_plugin.rb
@@ -248,7 +248,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin @@ -248,7 +248,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
248 end 248 end
249 249
250 def js_files 250 def js_files
251 - ["mpog-software.js", "mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js", "mpog-search.js", "jquery.maskedinput.min.js"] 251 + ["mpog-custom-libraries.js", "mpog-software.js", "mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js", "mpog-search.js", "jquery.maskedinput.min.js"]
252 end 252 end
253 253
254 def add_new_organization_buttons 254 def add_new_organization_buttons
public/mpog-custom-libraries.js 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +/*
  2 +* "Class" for select and option html generation
  3 +*/
  4 +var SelectElement = (function() {
  5 + function SelectElement(name, id) {
  6 + this.select = document.createElement("select");
  7 + }
  8 +
  9 + SelectElement.prototype.setAttr = function(attr, value) {
  10 + return this.select.setAttribute(attr, value);
  11 + };
  12 +
  13 + SelectElement.prototype.addOption = function(option) {
  14 + return this.select.add(option);
  15 + };
  16 +
  17 + SelectElement.prototype.getSelect = function() {
  18 + return this.select;
  19 + };
  20 +
  21 + SelectElement.generateOption = function(value, text) {
  22 + var option;
  23 + option = document.createElement("option");
  24 + option.setAttribute("value", value);
  25 + option.text = text;
  26 + return option;
  27 + };
  28 +
  29 + return SelectElement;
  30 +})();
0 \ No newline at end of file 31 \ No newline at end of file
public/mpog-institution-validations.js
@@ -181,11 +181,13 @@ @@ -181,11 +181,13 @@
181 jQuery(".intitution_cnpj_field").mask("99.999.999/9999-99"); 181 jQuery(".intitution_cnpj_field").mask("99.999.999/9999-99");
182 } 182 }
183 183
184 - function show_hide_cnpj_city() { 184 + function show_hide_cnpj_city(e) {
185 var cnpj = jQuery("#institutions_cnpj").parent().parent(); 185 var cnpj = jQuery("#institutions_cnpj").parent().parent();
186 var city = jQuery("#community_city").parent().parent(); 186 var city = jQuery("#community_city").parent().parent();
187 var state = jQuery("#community_state").parent().parent(); 187 var state = jQuery("#community_state").parent().parent();
188 188
  189 + if( this.value == "-1" ) jQuery(this).val("BR");
  190 +
189 if( this.value != "BR" ) { 191 if( this.value != "BR" ) {
190 cnpj.hide(); 192 cnpj.hide();
191 city.hide(); 193 city.hide();
@@ -195,21 +197,33 @@ @@ -195,21 +197,33 @@
195 city.show(); 197 city.show();
196 state.show(); 198 state.show();
197 } 199 }
  200 +
  201 + e.preventDefault();
198 } 202 }
199 203
200 - function set_events() {  
201 - show_private_institutions_fields(); 204 + function institution_type_actions() {
  205 + if( this.value == "PublicInstitution" )
  206 + show_public_institutions_fields();
  207 + else
  208 + show_private_institutions_fields();
  209 + }
  210 +
  211 + function set_form_count_custom_data() {
  212 + var divisor_option = SelectElement.generateOption("-1", "--------------------------------");
  213 + var default_option = SelectElement.generateOption("BR", "Brazil");
202 214
  215 + jQuery('#community_country').find("option[value='']").remove();
  216 + jQuery('#community_country').prepend(divisor_option);
  217 + jQuery('#community_country').prepend(default_option);
203 jQuery('#community_country').val("BR"); 218 jQuery('#community_country').val("BR");
  219 + }
  220 +
  221 + function set_events() {
  222 + show_private_institutions_fields();
204 223
205 jQuery("#create_institution_link").click(open_create_institution_modal); 224 jQuery("#create_institution_link").click(open_create_institution_modal);
206 225
207 - jQuery("input[type='radio']").click(function(){  
208 - if( this.value == "PublicInstitution" )  
209 - show_public_institutions_fields();  
210 - else  
211 - show_private_institutions_fields();  
212 - }); 226 + jQuery("input[type='radio']").click(institution_type_actions);
213 227
214 jQuery('#save_institution_button').click(save_institution); 228 jQuery('#save_institution_button').click(save_institution);
215 229
@@ -226,5 +240,8 @@ @@ -226,5 +240,8 @@
226 institution_autocomplete(); 240 institution_autocomplete();
227 } 241 }
228 242
229 - jQuery(document).ready(set_events); 243 + jQuery(document).ready(function(){
  244 + set_form_count_custom_data();
  245 + set_events();
  246 + });
230 })(); 247 })();
public/mpog-user-validations.js
1 (function(){ 1 (function(){
2 /* 2 /*
3 - * "Class" for select and option html generation  
4 - */  
5 - var SelectElement = (function() {  
6 - function SelectElement(name, id) {  
7 - this.select = document.createElement("select");  
8 - }  
9 -  
10 - SelectElement.prototype.setAttr = function(attr, value) {  
11 - return this.select.setAttribute(attr, value);  
12 - };  
13 -  
14 - SelectElement.prototype.addOption = function(option) {  
15 - return this.select.add(option);  
16 - };  
17 -  
18 - SelectElement.prototype.getSelect = function() {  
19 - return this.select;  
20 - };  
21 -  
22 - SelectElement.generateOption = function(value, text) {  
23 - var option;  
24 - option = document.createElement("option");  
25 - option.setAttribute("value", value);  
26 - option.text = text;  
27 - return option;  
28 - };  
29 -  
30 - return SelectElement;  
31 - })();  
32 -  
33 - /*  
34 * "Class" that switch state field between input and select 3 * "Class" that switch state field between input and select
35 * If the Country if Brazil, set state to select field 4 * If the Country if Brazil, set state to select field
36 * else set it as a input field 5 * else set it as a input field