Commit aeec2334d32c7b83a772aad97b3aac383bedf713
1 parent
7653601c
Exists in
master
and in
5 other branches
Show categories selected link when filter dont return software
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>t message for your changes. Lines starting
Showing
4 changed files
with
27 additions
and
14 deletions
Show diff stats
lib/ext/search_controller.rb
@@ -59,8 +59,8 @@ class SearchController | @@ -59,8 +59,8 @@ class SearchController | ||
59 | 59 | ||
60 | def get_filter_category_ids | 60 | def get_filter_category_ids |
61 | category_ids = [] | 61 | category_ids = [] |
62 | - unless params[:selected_categories].blank? | ||
63 | - category_ids = params[:selected_categories] | 62 | + unless params[:selected_categories_id].blank? |
63 | + category_ids = params[:selected_categories_id] | ||
64 | end | 64 | end |
65 | category_ids.map(&:to_i) | 65 | category_ids.map(&:to_i) |
66 | end | 66 | end |
@@ -115,9 +115,9 @@ class SearchController | @@ -115,9 +115,9 @@ class SearchController | ||
115 | 115 | ||
116 | def prepare_software_infos_params | 116 | def prepare_software_infos_params |
117 | @titles[:software_infos] = _("Public Software Catalog") | 117 | @titles[:software_infos] = _("Public Software Catalog") |
118 | - @selected_categories = params[:selected_categories] | ||
119 | - @selected_categories ||= [] | ||
120 | - @selected_categories = @selected_categories.map(&:to_i) | 118 | + @selected_categories_id = params[:selected_categories_id] |
119 | + @selected_categories_id ||= [] | ||
120 | + @selected_categories_id = @selected_categories_id.map(&:to_i) | ||
121 | @include_non_public = params[:include_non_public] == "true" | 121 | @include_non_public = params[:include_non_public] == "true" |
122 | @per_page = prepare_per_page | 122 | @per_page = prepare_per_page |
123 | end | 123 | end |
@@ -134,11 +134,13 @@ class SearchController | @@ -134,11 +134,13 @@ class SearchController | ||
134 | 134 | ||
135 | def prepare_software_infos_message | 135 | def prepare_software_infos_message |
136 | @message_selected_options = "" | 136 | @message_selected_options = "" |
137 | - unless @selected_categories.empty? | 137 | + |
138 | + @selected_categories = [] | ||
139 | + unless @selected_categories_id.empty? | ||
138 | @message_selected_options = _("Selected options: ") | 140 | @message_selected_options = _("Selected options: ") |
139 | 141 | ||
140 | - categories = Category.find(@selected_categories) | ||
141 | - @message_selected_options += categories.collect { |category| | 142 | + @selected_categories = Category.find(@selected_categories_id) |
143 | + @message_selected_options += @selected_categories.collect { |category| | ||
142 | "#{category.name}; " | 144 | "#{category.name}; " |
143 | }.join() | 145 | }.join() |
144 | end | 146 | end |
public/views/search-software-catalog.js
@@ -30,10 +30,10 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCat | @@ -30,10 +30,10 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCat | ||
30 | var params = {}; | 30 | var params = {}; |
31 | 31 | ||
32 | params.query = $("#search-input").val(); | 32 | params.query = $("#search-input").val(); |
33 | - params.selected_categories = []; | 33 | + params.selected_categories_id = []; |
34 | 34 | ||
35 | $(".categories-catalog:checked").each(function(index, element) { | 35 | $(".categories-catalog:checked").each(function(index, element) { |
36 | - params.selected_categories.push(element.value); | 36 | + params.selected_categories_id.push(element.value); |
37 | }); | 37 | }); |
38 | 38 | ||
39 | params.software_display = $("#software_display").val(); | 39 | params.software_display = $("#software_display").val(); |
@@ -69,18 +69,20 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCat | @@ -69,18 +69,20 @@ modulejs.define('SearchSoftwareCatalog', ['jquery', 'NoosferoRoot', 'SoftwareCat | ||
69 | var selected_categories_field = $("#filter-categories-select-catalog"); | 69 | var selected_categories_field = $("#filter-categories-select-catalog"); |
70 | var pagination = $("#software-pagination"); | 70 | var pagination = $("#software-pagination"); |
71 | var software_count = $("#software-count"); | 71 | var software_count = $("#software-count"); |
72 | + var individually_category = $("#individually-category"); | ||
72 | 73 | ||
73 | var result_list = response.find("#search-results").html(); | 74 | var result_list = response.find("#search-results").html(); |
74 | var result_categories = response.find("#filter-categories-select-catalog").html(); | 75 | var result_categories = response.find("#filter-categories-select-catalog").html(); |
75 | var result_pagination = response.find("#software-pagination").html(); | 76 | var result_pagination = response.find("#software-pagination").html(); |
76 | var result_software_count = response.find("#software-count").html(); | 77 | var result_software_count = response.find("#software-count").html(); |
77 | - | ||
78 | - | 78 | + var result_individually_category = response.find("#individually-category").html(); |
79 | 79 | ||
80 | search_list.html(result_list); | 80 | search_list.html(result_list); |
81 | selected_categories_field.html(result_categories); | 81 | selected_categories_field.html(result_categories); |
82 | pagination.html(result_pagination); | 82 | pagination.html(result_pagination); |
83 | software_count.html(result_software_count); | 83 | software_count.html(result_software_count); |
84 | + individually_category.html(result_individually_category); | ||
85 | + | ||
84 | highlight_searched_terms(); | 86 | highlight_searched_terms(); |
85 | catalog_message(); | 87 | catalog_message(); |
86 | 88 |
views/search/_catalog_filter.html.erb
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | <div id="gruop-catalog-01"> | 14 | <div id="gruop-catalog-01"> |
15 | <% @categories_groupe_one.each do |category| %> | 15 | <% @categories_groupe_one.each do |category| %> |
16 | <label> | 16 | <label> |
17 | - <%= check_box_tag("selected_categories[]", category.id, @selected_categories.include?(category.id), :class => "categories-catalog", @enabled_check_box[category] => "true") %> | 17 | + <%= check_box_tag("selected_categories_id[]", category.id, @selected_categories_id.include?(category.id), :class => "categories-catalog", @enabled_check_box[category] => "true") %> |
18 | <span><%= _("#{category.name}") %></span> | 18 | <span><%= _("#{category.name}") %></span> |
19 | </label> <br> | 19 | </label> <br> |
20 | <% end %> | 20 | <% end %> |
@@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
22 | <div id="group-catalog-02"> | 22 | <div id="group-catalog-02"> |
23 | <% @categories_groupe_two.each do |category| %> | 23 | <% @categories_groupe_two.each do |category| %> |
24 | <label> | 24 | <label> |
25 | - <%= check_box_tag("selected_categories[]", category.id, @selected_categories.include?(category.id), :class => "categories-catalog", @enabled_check_box[category] => "true") %> | 25 | + <%= check_box_tag("selected_categories_id[]", category.id, @selected_categories_id.include?(category.id), :class => "categories-catalog", @enabled_check_box[category] => "true") %> |
26 | <%= _("#{category.name}") %> | 26 | <%= _("#{category.name}") %> |
27 | </label> <br> | 27 | </label> <br> |
28 | <% end %> | 28 | <% end %> |
views/search/_catalog_result_list.html.erb
@@ -33,7 +33,16 @@ | @@ -33,7 +33,16 @@ | ||
33 | <div id="search-results-empty"></div> | 33 | <div id="search-results-empty"></div> |
34 | 34 | ||
35 | <input type="hidden" id="message-no-catalog-selected" value="<%= _('No software found. Try more general filters') %>" /> | 35 | <input type="hidden" id="message-no-catalog-selected" value="<%= _('No software found. Try more general filters') %>" /> |
36 | + | ||
36 | <input type="hidden" id="message-catalog-selected" value="<%= _('No software found. Try more general filters or check the software category individually') %>" /> | 37 | <input type="hidden" id="message-catalog-selected" value="<%= _('No software found. Try more general filters or check the software category individually') %>" /> |
38 | + | ||
39 | + <div id="individually-category"> | ||
40 | + <% @selected_categories.each do |category| %> | ||
41 | + <br /> | ||
42 | + <%= link_to _("#{category.name}") + " (#{category.software_infos.count})", {:controller => :search, :action => :software_infos, :selected_categories_id => [category.id]} %> | ||
43 | + <% end %> | ||
44 | + </div> | ||
45 | + | ||
37 | <% end %> | 46 | <% end %> |
38 | </div> | 47 | </div> |
39 | <% end %> | 48 | <% end %> |