Commit e80e402809e470678f66f31a46673c36fe28275d

Authored by Rodrigo Souto
1 parent 20566b3e

Filter selector

app/helpers/search_helper.rb
... ... @@ -23,6 +23,13 @@ module SearchHelper
23 23 :products => 'full',
24 24 }
25 25  
  26 + FILTER_TRANSLATION = {
  27 + 'more_popular' => _('More popular'),
  28 + 'more_active' => _('More active'),
  29 + 'more_recent' => _('More recent'),
  30 + 'more_comments' => _('More comments')
  31 + }
  32 +
26 33 # FIXME remove it after search_controler refactored
27 34 include EventsHelper
28 35  
... ... @@ -95,8 +102,20 @@ module SearchHelper
95 102 full_link = display_full?(asset) ? (display == 'full' ? _('Full') : link_to(_('Full'), params.merge(:display => 'full'))) : nil
96 103 content_tag('div',
97 104 content_tag('strong', _('Display')) + ': ' + [compact_link, map_link, full_link].compact.join(' | '),
98   - :id => 'search-display-filter',
99   - :style => "float: #{float}"
  105 + :class => 'search-customize-options'
  106 + )
  107 + end
  108 + end
  109 +
  110 + def filter_selector(asset, filter, float = 'right')
  111 + klass = asset_class(asset)
  112 + if klass::SEARCH_FILTERS.count > 1
  113 + options = options_for_select(klass::SEARCH_FILTERS.map {|f| [FILTER_TRANSLATION[f], f]}, filter)
  114 + onchange = "document.location.href = document.location.search.replace(/filter=[^&]*|$/,'&filter='+this.value)"
  115 + select_field = select_tag(:filter, options, :onchange => onchange)
  116 + content_tag('div',
  117 + content_tag('strong', _('Filter')) + ': ' + select_field,
  118 + :class => "search-customize-options"
100 119 )
101 120 end
102 121 end
... ...
app/views/search/_display_results.rhtml
... ... @@ -10,7 +10,6 @@
10 10 <% if search[:results].total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %>
11 11 <%= link_to(_('see all (%d)') % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %>
12 12 <% end %>
13   - <% params[:display] = 'compact' %>
14 13 <% end %>
15 14  
16 15 <div class="search-results-innerbox search-results-type-<%= name.to_s %> <%= 'common-profile-list-block' if [:enterprises, :people, :communities].include?(name) %>">
... ...
app/views/search/_results_header.rhtml
1 1 <div class="search-results-header <%= "search-no-results" if @searches[@asset].nil? or @searches[@asset].length == 0 %>">
2 2 <div id='search-filter-title'><%= filter_title(@asset, @filter) %></div>
3 3 <%= display_selector(@asset, params[:display]) %>
  4 + <%= filter_selector(@asset, @filter)%>
4 5 <div style="clear: both"></div>
5 6 </div>
... ...
public/stylesheets/search.css
... ... @@ -6,6 +6,18 @@
6 6 position: relative; /* to the text appear on MSIE 6 */
7 7 width: 100%;
8 8 }
  9 +
  10 +.controller-search .search-field .formfield {
  11 + width: 805px;
  12 + display: inline-block;
  13 +}
  14 +
  15 +.controller-search #content form input.button.submit {
  16 + display: inline-block;
  17 + height: 25px;
  18 + max-height: 25px;
  19 + width: 87px;
  20 +}
9 21 .controller-search .current-cat-path {
10 22 padding-left: 25px;
11 23 }
... ... @@ -642,6 +654,7 @@ li.search-product-item hr {
642 654 padding: 6px 0px 0px 0px;
643 655 margin:0 0 5px 0;
644 656 border-bottom: 2px dotted #999;
  657 + text-align: right;
645 658 }
646 659 #search-filter-title {
647 660 font-weight: bold;
... ... @@ -666,8 +679,10 @@ li.search-product-item hr {
666 679 color: #ff0000
667 680 }
668 681  
669   -#search-display-filter {
670   - margin-top: 20px;
  682 +.search-customize-options {
  683 + display: inline-block;
  684 + margin-left: 8px;
  685 + margin-top: 10px;
671 686 }
672 687  
673 688 /* Search field and button */
... ...