Commit 893e3c6e5eae0b308ab982c112f9982fbf66c55f
1 parent
60853dc5
Exists in
master
and in
5 other branches
Fix addition of categories as filters
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
3 changed files
with
47 additions
and
37 deletions
Show diff stats
lib/ext/search_controller.rb
@@ -11,13 +11,13 @@ class SearchController | @@ -11,13 +11,13 @@ class SearchController | ||
11 | 11 | ||
12 | def software_infos | 12 | def software_infos |
13 | @titles[:software_infos] = "Software Infos" | 13 | @titles[:software_infos] = "Software Infos" |
14 | + @category_filters = [] | ||
14 | 15 | ||
15 | if params[:filter].blank? | 16 | if params[:filter].blank? |
16 | results = filter_communities_list{|community| community.software?} | 17 | results = filter_communities_list{|community| community.software?} |
17 | else | 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 | end | 21 | end |
22 | 22 | ||
23 | results = results.paginate(:per_page => 24, :page => params[:page]) | 23 | results = results.paginate(:per_page => 24, :page => params[:page]) |
public/software-catalog.js
@@ -9,10 +9,8 @@ | @@ -9,10 +9,8 @@ | ||
9 | function create_catalog_element(first, value, id) { | 9 | function create_catalog_element(first, value, id) { |
10 | var li_tag = document.createElement("li"); | 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 | return li_tag; | 15 | return li_tag; |
18 | } | 16 | } |
@@ -88,12 +86,7 @@ | @@ -88,12 +86,7 @@ | ||
88 | jQuery(".catalog-remove-item").click(remote_catalog_item); | 86 | jQuery(".catalog-remove-item").click(remote_catalog_item); |
89 | } | 87 | } |
90 | 88 | ||
91 | - function clear_filters() { | ||
92 | - jQuery("#filter").val(""); | ||
93 | - } | ||
94 | - | ||
95 | jQuery(document).ready(function(){ | 89 | jQuery(document).ready(function(){ |
96 | - clear_filters(); | ||
97 | set_autocomplate(); | 90 | set_autocomplate(); |
98 | set_events(); | 91 | set_events(); |
99 | }); | 92 | }); |
views/search/_catalog_filter.html.erb
1 | +<!-- Remove CSS when design team send corrections --> | ||
1 | <style type="text/css"> | 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 | </style> | 35 | </style> |
25 | 36 | ||
26 | <div> | 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 | </div> | 51 | </div> |
35 | \ No newline at end of file | 52 | \ No newline at end of file |