Commit 3ae1972bfe091554dd0aa61bfe9e84c5322f59f6

Authored by Gabriela Navarro
Committed by Parley
1 parent f9f6d523
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

more_inst_for_users: Add more institutions for user registration

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
lib/mpog_software_plugin.rb
... ... @@ -41,13 +41,16 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
41 41 content_tag(:div,
42 42 labelled_form_field(
43 43 _('Institution'),
44   - text_field(:institution, :name, :id => 'input_institution')+
  44 + content_tag(:div,
  45 + text_field(:institution, :name, :class=>"input_institution"),
  46 + :class => 'institution_container')+
45 47 content_tag(
46 48 :small, _('Fill with your institution') ,:class => 'signup-form', :id =>'institution-balloon'
47 49 ) +
48 50 content_tag(:div, _("The searched institution does not exist"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") +
49   - link_to(_("Add new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add')+
50   - hidden_field_tag("user[institution_id]", "", :id => 'user_institution_id')+
  51 + link_to(_("Add new institution"), "#", :class=>'button with-text icon-add add_new_institution') +
  52 + link_to(_("Create new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add')+
  53 + hidden_field_tag("user[institutions][]", "", :class => 'user_institutions')+
51 54 content_tag(:div, "", :id=>"institution_dialog")
52 55 ),
53 56 :id => 'signup-institution'
... ...
public/mpog-institution-validations.js
... ... @@ -113,6 +113,50 @@
113 113 }
114 114 }
115 115  
  116 +
  117 + function institution_autocomplete() {
  118 + jQuery(".input_institution").autocomplete({
  119 + source : function(request, response){
  120 + jQuery.ajax({
  121 + type: "GET",
  122 + url: "/plugin/mpog_software/get_institutions",
  123 + data: {query: request.term},
  124 + success: function(result){
  125 + response(result);
  126 +
  127 + if( result.length == 0 ) {
  128 + jQuery('#institution_empty_ajax_message').switchClass("hide-field", "show-field");
  129 + } else {
  130 + jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
  131 + }
  132 + },
  133 + error: function(ajax, stat, errorThrown) {
  134 + console.log('Link not found : ' + errorThrown);
  135 + }
  136 + });
  137 + },
  138 +
  139 + minLength: 2,
  140 +
  141 + select : function (event, selected) {
  142 + var user_institutions = jQuery(".user_institutions").first().clone();
  143 + user_institutions.val(selected.item.id);
  144 +
  145 + jQuery(".institution_container").append(user_institutions);
  146 + }
  147 + });
  148 + }
  149 +
  150 + function add_new_institution(evt) {
  151 + evt.preventDefault();
  152 + var institution_input_field = jQuery(".institution_container .input_institution").first().clone();
  153 +
  154 + institution_input_field.val("");
  155 +
  156 + jQuery(".institution_container").append(institution_input_field);
  157 + institution_autocomplete();
  158 + }
  159 +
116 160 function set_events() {
117 161 jQuery("#create_institution_link").click(open_create_institution_modal);
118 162  
... ... @@ -123,7 +167,16 @@
123 167 jQuery('#save_institution_button').click(save_institution);
124 168  
125 169 jQuery("#community_name").keyup(institution_already_exists);
  170 +
  171 + jQuery(".add_new_institution").click(add_new_institution);
  172 +
  173 + institution_autocomplete();
  174 +
  175 + jQuery(".input_institution").blur(function(){
  176 + if( this.value == "" )
  177 + jQuery("#user_institution_id").val("");
  178 + });
126 179 }
127 180  
128 181 jQuery(document).ready(set_events);
129   -})();
130 182 \ No newline at end of file
  183 +})();
... ...
public/mpog-user-validations.js
... ... @@ -42,36 +42,6 @@ function validate_email_format(){
42 42 this.className = "";
43 43 }
44 44  
45   -function institution_autocomplete() {
46   - jQuery("#input_institution").autocomplete({
47   - source : function(request, response){
48   - jQuery.ajax({
49   - type: "GET",
50   - url: "/plugin/mpog_software/get_institutions",
51   - data: {query: request.term},
52   - success: function(result){
53   - response(result);
54   -
55   - if( result.length == 0 ) {
56   - jQuery('#institution_empty_ajax_message').switchClass("hide-field", "show-field");
57   - } else {
58   - jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
59   - }
60   - },
61   - error: function(ajax, stat, errorThrown) {
62   - console.log('Link not found : ' + errorThrown);
63   - }
64   - });
65   - },
66   -
67   - minLength: 2,
68   -
69   - select : function (event, selected) {
70   - jQuery("#user_institution_id").val(selected.item.id);
71   - }
72   - });
73   -}
74   -
75 45  
76 46 jQuery(document).ready(function(){
77 47 jQuery('#secondary_email_field').blur(
... ... @@ -90,11 +60,4 @@ jQuery(document).ready(function(){
90 60  
91 61 jQuery('#area_interest_field').focus(function() { jQuery('#area-interest-balloon').fadeIn('slow'); });
92 62 jQuery('#area_interest_field').blur(function() { jQuery('#area-interest-balloon').fadeOut('slow'); });
93   -
94   - institution_autocomplete();
95   -
96   - jQuery("#input_institution").blur(function(){
97   - if( this.value == "" )
98   - jQuery("#user_institution_id").val("");
99   - });
100 63 });
... ...