Commit ea527e8a7f2df9105cae1050aace77f1b735da24
Committed by
Luciano Prestes
1 parent
a4819142
Exists in
master
and in
54 other branches
Disable categories without software in software catalog
Signed_off_by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Showing
2 changed files
with
16 additions
and
2 deletions
Show diff stats
lib/ext/search_controller.rb
| @@ -110,6 +110,7 @@ class SearchController | @@ -110,6 +110,7 @@ class SearchController | ||
| 110 | prepare_software_infos_params | 110 | prepare_software_infos_params |
| 111 | prepare_software_infos_message | 111 | prepare_software_infos_message |
| 112 | prepare_software_infos_category_groups | 112 | prepare_software_infos_category_groups |
| 113 | + prepare_software_infos_category_enable | ||
| 113 | end | 114 | end |
| 114 | 115 | ||
| 115 | def prepare_software_infos_params | 116 | def prepare_software_infos_params |
| @@ -155,4 +156,17 @@ class SearchController | @@ -155,4 +156,17 @@ class SearchController | ||
| 155 | end | 156 | end |
| 156 | end | 157 | end |
| 157 | 158 | ||
| 159 | + def prepare_software_infos_category_enable | ||
| 160 | + @enabled_check_box = Hash.new | ||
| 161 | + categories = Category.software_categories | ||
| 162 | + | ||
| 163 | + categories.each do |category| | ||
| 164 | + if category.software_infos.count > 0 | ||
| 165 | + @enabled_check_box[category] = :enabled | ||
| 166 | + else | ||
| 167 | + @enabled_check_box[category] = :disabled | ||
| 168 | + end | ||
| 169 | + end | ||
| 170 | + end | ||
| 171 | + | ||
| 158 | end | 172 | end |
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") %> | 17 | + <%= check_box_tag("selected_categories[]", category.id, @selected_categories.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") %> | 25 | + <%= check_box_tag("selected_categories[]", category.id, @selected_categories.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 %> |