Commit 893e3c6e5eae0b308ab982c112f9982fbf66c55f

Authored by Luciano Prestes
1 parent 60853dc5
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 addition of categories as filters

Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
lib/ext/search_controller.rb
... ... @@ -11,13 +11,13 @@ class SearchController
11 11  
12 12 def software_infos
13 13 @titles[:software_infos] = "Software Infos"
  14 + @category_filters = []
14 15  
15 16 if params[:filter].blank?
16 17 results = filter_communities_list{|community| community.software?}
17 18 else
18   - integer_filters = []
19   - params[:filter].split(",").each{|f| integer_filters << f.to_i}
20   - results = filter_communities_list{|community| community.software? && !(community.category_ids & integer_filters).blank?}
  19 + params[:filter].split(",").each{|f| @category_filters << f.to_i}
  20 + results = filter_communities_list{|community| community.software? && !(community.category_ids & @category_filters).blank?}
21 21 end
22 22  
23 23 results = results.paginate(:per_page => 24, :page => params[:page])
... ...
public/software-catalog.js
... ... @@ -9,10 +9,8 @@
9 9 function create_catalog_element(first, value, id) {
10 10 var li_tag = document.createElement("li");
11 11  
12   - if( first )
13   - li_tag.innerHTML = value + " <span class='catalog-remove-item' data-id='"+id+"'>x</span>";
14   - else
15   - li_tag.innerHTML = ", " + value + " <span class='catalog-remove-item' data-id='"+id+"'>x</span>";
  12 + li_tag.className = "category_box";
  13 + li_tag.innerHTML = value + " <span class='catalog-remove-item' data-id='"+id+"'>x</span>";
16 14  
17 15 return li_tag;
18 16 }
... ... @@ -88,12 +86,7 @@
88 86 jQuery(".catalog-remove-item").click(remote_catalog_item);
89 87 }
90 88  
91   - function clear_filters() {
92   - jQuery("#filter").val("");
93   - }
94   -
95 89 jQuery(document).ready(function(){
96   - clear_filters();
97 90 set_autocomplate();
98 91 set_events();
99 92 });
... ...
views/search/_catalog_filter.html.erb
  1 +<!-- Remove CSS when design team send corrections -->
1 2 <style type="text/css">
2   - #catalog-list ul li {
3   - display: inline;
4   - margin-right: 5px;
5   - font-size: 14px;
6   - padding: 5px;
7   - }
  3 + #catalog-list ul li {
  4 + display: inline;
  5 + margin-right: 5px;
  6 + font-size: 14px;
  7 + padding: 5px;
  8 + }
8 9  
9   - #catalog-list ul li span {
10   - display: none;
11   - cursor: pointer;
12   - }
  10 + #catalog-list ul li span {
  11 + display: none;
  12 + cursor: pointer;
  13 + }
13 14  
14   - #catalog-list ul li:hover span {
15   - display: inline-block;
16   - }
  15 + #catalog-list ul li:hover span {
  16 + display: inline-block;
  17 + }
17 18  
18   - .catalog-remove-item {
19   - padding: 3px;
20   - border: solid 1px #999;
21   - border-radius: 3px;
22   - background: #d4d4d4;
23   - }
  19 + .catalog-remove-item {
  20 + padding: 3px;
  21 + border: solid 1px #999;
  22 + border-radius: 3px;
  23 + background: #d4d4d4;
  24 + }
  25 +
  26 + .category_box {
  27 + font-size: 11px !important;
  28 + border:1px solid #e9e8ed;
  29 + border-radius:8px;
  30 + background-color:#e9e8ed;
  31 + padding:3px 6px;
  32 + margin:10px 3px;
  33 + color: blue;
  34 + }
24 35 </style>
25 36  
26 37 <div>
27   - <div id="catalog-list">
28   - <ul></ul>
29   - </div>
  38 + <div id="catalog-list">
  39 + <ul>
  40 + <% @category_filters.each do |filter_id| %>
  41 + <li class="category_box"> <%= _(Category.find(filter_id).name) %>
  42 + <span class="catalog-remove-item" data-id="<%= filter_id %>" >x</span>
  43 + </li>
  44 + <% end %>
  45 + </ul>
  46 + </div>
30 47  
31   - <div id="catalog-filter">
32   - <%= text_field(:software, :catalog, :id=>"software-catalog") %>
33   - </div>
  48 + <div id="catalog-filter">
  49 + <%= text_field(:software, :catalog, :id=>"software-catalog") %>
  50 + </div>
34 51 </div>
35 52 \ No newline at end of file
... ...