Commit db20687826650adc205ae21712c4976273f70a8c

Authored by Luciano Prestes
Committed by Álvaro Fernando Matos de Souza
1 parent 8c6e1dba
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 radio_buttons for search type of software

lib/ext/search_controller.rb
... ... @@ -80,7 +80,7 @@ class SearchController
80 80 def get_communities_list software_list
81 81 filtered_community_list = []
82 82 software_list.each do |software|
83   - if @include_non_public || software.public_software?
  83 + if @all_selected || software.public_software?
84 84 filtered_community_list << software.community unless software.community.nil?
85 85 end
86 86 end
... ... @@ -110,7 +110,8 @@ class SearchController
110 110 @selected_categories_id = params[:selected_categories_id]
111 111 @selected_categories_id ||= []
112 112 @selected_categories_id = @selected_categories_id.map(&:to_i)
113   - @include_non_public = params[:include_non_public] == "true"
  113 + @all_selected = params[:software_type] == "all"
  114 + @public_software_selected = !@all_selected
114 115 @per_page = prepare_per_page
115 116 end
116 117  
... ...
public/views/search-software-catalog.js
... ... @@ -39,7 +39,11 @@ modulejs.define(&#39;SearchSoftwareCatalog&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SoftwareCat
39 39 params.software_display = $("#software_display").val();
40 40 params.sort = $("#sort").val();
41 41  
42   - params.include_non_public = $("#include_non_public").is(":checked");
  42 + if($("#all_radio_button").is(":checked")) {
  43 + params.software_type = $("#all_radio_button").val();
  44 + } else {
  45 + params.software_type = $("#public_software_radio_button").val();
  46 + }
43 47  
44 48 return params;
45 49 }
... ...
views/search/_catalog_filter.html.erb
... ... @@ -12,14 +12,6 @@
12 12 <% end %>
13 13 </ul>
14 14 </div>
15   -
16   - <div class="project-software"> <%= _("Software Projects:") %>
17   - <label>
18   - <%= check_box_tag("include_non_public", true, @include_non_public) %>
19   - <%= _("Include in results") %>
20   - </label>
21   - <span class="doubts-catalog-software" title="<%= _('Include software development projects that are not yet officially Brazilian Public Software.') %>">?</span>
22   - </div>
23 15 </div>
24 16 <div id="filter-option-catalog-software"><%= _("More options") %></div>
25 17 <div id="filter-option-catalog-close">
... ...
views/search/_software_search_form.html.erb
... ... @@ -5,19 +5,22 @@
5 5 <%= form_tag( { :controller => 'search', :action => @asset ? @asset : 'index', :asset => nil, :category_path => ( @category ? @category.path : nil ) },
6 6 :method => 'get') do %>
7 7  
8   - <div style="margin:0;padding:0;display:inline">
9   - <input name="utf8" type="hidden" value="&#x2713;" />
10   - </div>
11   - <%= hidden_field_tag :display, params[:display] %>
12   - <%= hidden_field_tag :filter, params[:filter] %>
  8 + <div style="margin:0;padding:0;display:inline">
  9 + <input name="utf8" type="hidden" value="&#x2713;" /></div>
  10 +
  11 + <%= hidden_field_tag :display, params[:display] %>
  12 + <%= hidden_field_tag :filter, params[:filter] %>
  13 +
  14 + <%= labelled_radio_button _('Public Software'), :software_type, 'public_software', @public_software_selected, :id => "public_software_radio_button", :class => "project-software" %>
  15 + <%= labelled_radio_button _('All'), :software_type, 'all', @all_selected, :id => "all_radio_button", :class => "project-software" %>
13 16  
14   - <div class="search-field">
15   - <span class="formfield">
16   - <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50, :placeholder=>_("Type words about the software you're looking for (the search begins after 3 characters)") %>
17   - </span>
  17 + <div class="search-field">
  18 + <span class="formfield">
  19 + <%= text_field_tag 'query', @query, :id => 'search-input', :size => 50, :placeholder=>_("Type words about the software you're looking for (the search begins after 3 characters)") %>
  20 + </span>
18 21  
19 22 <%= submit_button(:search, _('Filter')) %>
20   - </div>
  23 + </div>
21 24 <%= render :partial => 'search_form_extra_fields' %>
22 25 <%= render :partial => 'catalog_filter' %>
23 26 <% end %>
... ...