Commit e80e402809e470678f66f31a46673c36fe28275d
1 parent
20566b3e
Exists in
staging
and in
42 other branches
Filter selector
Showing
4 changed files
with
39 additions
and
5 deletions
Show diff stats
app/helpers/search_helper.rb
| @@ -23,6 +23,13 @@ module SearchHelper | @@ -23,6 +23,13 @@ module SearchHelper | ||
| 23 | :products => 'full', | 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 | # FIXME remove it after search_controler refactored | 33 | # FIXME remove it after search_controler refactored |
| 27 | include EventsHelper | 34 | include EventsHelper |
| 28 | 35 | ||
| @@ -95,8 +102,20 @@ module SearchHelper | @@ -95,8 +102,20 @@ module SearchHelper | ||
| 95 | full_link = display_full?(asset) ? (display == 'full' ? _('Full') : link_to(_('Full'), params.merge(:display => 'full'))) : nil | 102 | full_link = display_full?(asset) ? (display == 'full' ? _('Full') : link_to(_('Full'), params.merge(:display => 'full'))) : nil |
| 96 | content_tag('div', | 103 | content_tag('div', |
| 97 | content_tag('strong', _('Display')) + ': ' + [compact_link, map_link, full_link].compact.join(' | '), | 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 | end | 120 | end |
| 102 | end | 121 | end |
app/views/search/_display_results.rhtml
| @@ -10,7 +10,6 @@ | @@ -10,7 +10,6 @@ | ||
| 10 | <% if search[:results].total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %> | 10 | <% if search[:results].total_entries > SearchController::MULTIPLE_SEARCH_LIMIT %> |
| 11 | <%= link_to(_('see all (%d)') % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %> | 11 | <%= link_to(_('see all (%d)') % search[:results].total_entries, params.merge(:action => name), :class => 'see-more' ) %> |
| 12 | <% end %> | 12 | <% end %> |
| 13 | - <% params[:display] = 'compact' %> | ||
| 14 | <% end %> | 13 | <% end %> |
| 15 | 14 | ||
| 16 | <div class="search-results-innerbox search-results-type-<%= name.to_s %> <%= 'common-profile-list-block' if [:enterprises, :people, :communities].include?(name) %>"> | 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 | <div class="search-results-header <%= "search-no-results" if @searches[@asset].nil? or @searches[@asset].length == 0 %>"> | 1 | <div class="search-results-header <%= "search-no-results" if @searches[@asset].nil? or @searches[@asset].length == 0 %>"> |
| 2 | <div id='search-filter-title'><%= filter_title(@asset, @filter) %></div> | 2 | <div id='search-filter-title'><%= filter_title(@asset, @filter) %></div> |
| 3 | <%= display_selector(@asset, params[:display]) %> | 3 | <%= display_selector(@asset, params[:display]) %> |
| 4 | + <%= filter_selector(@asset, @filter)%> | ||
| 4 | <div style="clear: both"></div> | 5 | <div style="clear: both"></div> |
| 5 | </div> | 6 | </div> |
public/stylesheets/search.css
| @@ -6,6 +6,18 @@ | @@ -6,6 +6,18 @@ | ||
| 6 | position: relative; /* to the text appear on MSIE 6 */ | 6 | position: relative; /* to the text appear on MSIE 6 */ |
| 7 | width: 100%; | 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 | .controller-search .current-cat-path { | 21 | .controller-search .current-cat-path { |
| 10 | padding-left: 25px; | 22 | padding-left: 25px; |
| 11 | } | 23 | } |
| @@ -642,6 +654,7 @@ li.search-product-item hr { | @@ -642,6 +654,7 @@ li.search-product-item hr { | ||
| 642 | padding: 6px 0px 0px 0px; | 654 | padding: 6px 0px 0px 0px; |
| 643 | margin:0 0 5px 0; | 655 | margin:0 0 5px 0; |
| 644 | border-bottom: 2px dotted #999; | 656 | border-bottom: 2px dotted #999; |
| 657 | + text-align: right; | ||
| 645 | } | 658 | } |
| 646 | #search-filter-title { | 659 | #search-filter-title { |
| 647 | font-weight: bold; | 660 | font-weight: bold; |
| @@ -666,8 +679,10 @@ li.search-product-item hr { | @@ -666,8 +679,10 @@ li.search-product-item hr { | ||
| 666 | color: #ff0000 | 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 | /* Search field and button */ | 688 | /* Search field and button */ |