Commit 8f2bf86367ee365114d484c186008f67b05c04a5

Authored by Fabio Teixeira
1 parent 3dbe1ff5
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

software_search: Replacing plugin's custom searches for one more generic

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
lib/mpog_software_plugin.rb
... ... @@ -329,28 +329,34 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
329 329 if context.params[:action] == "people"
330 330 expanded_template('search/search_user_filter.html.erb')
331 331 else context.params[:action] == "communities"
  332 + @active_type = if context.params[:type] == "Software"
  333 + "software"
  334 + elsif context.params[:type] == "Institution"
  335 + "institution"
  336 + else
  337 + "community"
  338 + end
  339 +
332 340 expanded_template('search/search_community_filter.html.erb')
333 341 end
334 342 end
335 343  
336   - def custom_people_search params
337   - Person.search(params[:name],
338   - params[:state],
339   - params[:city],
340   - params[:email]
341   - )
342   - end
  344 + def custom_search params
  345 + #:params => {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>"1", "programming_language"=>"1", "operating_system"=>"1", "controlled_vocabulary"=>"Administration", "license_info"=>{"id"=>""}, "e_ping"=>"any", "e_mag"=>"any", "icp_brasil"=>"any", "e_arq"=>"any", "internacionalizable"=>"any", "commit"=>"Search", "controller"=>"search", "action"=>"communities"}
343 346  
344   - def custom_community_search params
345   - if params[:type] == "Community"
346   - Community.search(params[:name])
347   - elsif params[:type] == "Software"
348   -
349   - elsif params[:type] == "Institution"
  347 + if params[:action] == "people"
  348 + Person.search(params[:name],
  349 + params[:state],
  350 + params[:city],
  351 + params[:email]
  352 + )
  353 + elsif params[:action] == "communities" and params[:type] == "Institution"
350 354  
351   - else
  355 + elsif params[:action] == "communities" and params[:type] == "Software"
352 356  
353   - end
  357 + else
  358 + [] # An empty list will trigger noosfero's default communities search
  359 + end
354 360 end
355 361  
356 362 def controlled_vocabulary_transaction
... ...
public/mpog-search.js
... ... @@ -18,8 +18,20 @@
18 18 jQuery(".community_fields").show();
19 19 }
20 20  
  21 + function display_search_fields_on_page_load() {
  22 + var active_search = jQuery(".search_type input[checked='checked'").val();
  23 +
  24 + switch(active_search) {
  25 + case "Community": show_community_fields(); break;
  26 + case "Software": show_software_fields(); break;
  27 + case "Institution": show_institutions_fields(); break;
  28 +
  29 + default: show_community_fields();
  30 + }
  31 + }
  32 +
21 33 function set_events() {
22   - show_community_fields();
  34 + display_search_fields_on_page_load();
23 35  
24 36 jQuery("#type_Community").click(show_community_fields);
25 37  
... ...
views/search/search_community_filter.html.erb
... ... @@ -2,15 +2,15 @@
2 2 <div id="search_content">
3 3  
4 4 <div class="search_options">
5   - <table class="mpog_search_form_table formfield type-radio">
  5 + <table class="mpog_search_form_table formfield type-radio search_type">
6 6 <tr>
7 7 <td>
8 8 <%= label_tag("type_Community", _("Community")) %>
9   - <%= radio_button_tag(:type, "Community", true) %>
  9 + <%= radio_button_tag(:type, "Community", (true if @active_type == "community")) %>
10 10 <%= label_tag("type_Software", _("Software")) %>
11   - <%= radio_button_tag(:type, "Software") %>
  11 + <%= radio_button_tag(:type, "Software", (true if @active_type == "software")) %>
12 12 <%= label_tag("type_Institution", _("Institution")) %>
13   - <%= radio_button_tag(:type, "Institution") %>
  13 + <%= radio_button_tag(:type, "Institution", (true if @active_type == "institution")) %>
14 14 </td>
15 15 </tr>
16 16 </table>
... ...
views/search/search_forms/_community_fields.html.erb
1 1 <table class="mpog_search_form_table">
2 2 <tr>
3 3 <td>
4   - <%= label_tag("name", _("Name"))%>
5   - <%= text_field_tag(:name) %>
  4 + <input id="search-input" name="query" size="50" type="text" value="" title="<%= _('Type words about the community you are looking for') %>">
6 5 </td>
7 6 </tr>
8   -</table>
9 7 \ No newline at end of file
  8 +</table>
... ...