Commit 15f8ee56f16089d0f1f9fe43a4f8ec1187eaddf6
1 parent
6b85a7bc
Exists in
master
and in
29 other branches
Helpers for order and found label
Showing
1 changed file
with
28 additions
and
3 deletions
Show diff stats
app/helpers/search_helper.rb
... | ... | @@ -134,11 +134,36 @@ module SearchHelper |
134 | 134 | asset_class(asset).table_name |
135 | 135 | end |
136 | 136 | |
137 | - def order_by(asset, options) | |
137 | + def order_by(asset) | |
138 | + options = { | |
139 | + :products => [[_('Best match'), ''], [_('Name'), 'name_sort asc'], [_('Lower price'), 'price asc'], [_('Higher price'), 'price desc']], | |
140 | + :events => [[_('Best match'), ''], [_('Name'), 'name_sort asc']], | |
141 | + :articles => [[_('Best match'), ''], [_('Name'), 'name_sort asc'], [_('Most recent'), 'updated_at desc']], | |
142 | + :enterprises => [[_('Best match'), ''], [_('Name'), 'name_sort asc']], | |
143 | + :people => [[_('Best match'), ''], [_('Name'), 'name_sort asc']], | |
144 | + :communities => [[_('Best match'), ''], [_('Name'), 'name_sort asc']], | |
145 | + } | |
146 | + | |
138 | 147 | content_tag('div', _('Order by ') + |
139 | - select_tag(asset.to_s + '[order]', options_for_select(options, params[:order_by]), | |
140 | - {:onchange => "window.location=jQuery.param.querystring(window.location.href, { 'order_by' : this.options[this.selectedIndex].value})"}), | |
148 | + select_tag(asset.to_s + '[order]', options_for_select(options[asset], params[:order_by]), | |
149 | + {:onchange => "window.location=jQuery.param.querystring(window.location.href, { 'order_by' : this.options[this.selectedIndex].value})"}), | |
141 | 150 | :class => "search-ordering") |
142 | 151 | end |
143 | 152 | |
153 | + def label_total_found(asset, total_found) | |
154 | + labels = { | |
155 | + :products => _("%s products offers found"), | |
156 | + :articles => _("%s articles found"), | |
157 | + :events => _("%s events found"), | |
158 | + :people => _("%s people found"), | |
159 | + :enterprises => _("%s enterprises found"), | |
160 | + :communities => _("%s communities found"), | |
161 | + } | |
162 | + if labels[asset] | |
163 | + content_tag('span', labels[asset] % total_found, | |
164 | + :class => "total-pages-found") | |
165 | + else | |
166 | + '' | |
167 | + end | |
168 | + end | |
144 | 169 | end | ... | ... |