Module: Workarea::FacetsHelper
- Defined in:
- app/helpers/workarea/facets_helper.rb
Instance Method Summary collapse
- #facet_hidden_inputs(facets) ⇒ Object
- #facet_path(facet, value) ⇒ Object
- #price_range_facet_text(range) ⇒ Object
Instance Method Details
#facet_hidden_inputs(facets) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/workarea/facets_helper.rb', line 33 def facet_hidden_inputs(facets) result = '' params.slice(*facets.map(&:system_name)).each_pair do |key, value| if value.respond_to?(:map) value.map do |val| result << hidden_field_tag( "#{key}[]", val, id: nil ) end else result << hidden_field_tag("#{key}[]", value) end end result.html_safe end |
#facet_path(facet, value) ⇒ Object
3 4 5 6 7 |
# File 'app/helpers/workarea/facets_helper.rb', line 3 def facet_path(facet, value) link_params = facet.params_for(value) link_params[:only_path] = true url_for(link_params) end |
#price_range_facet_text(range) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/workarea/facets_helper.rb', line 9 def price_range_facet_text(range) result = '' if range[:from].blank? price = number_to_currency(range[:to].to_m) return t('workarea.facets.price_range.under', price: price).html_safe elsif range[:to].present? result << number_to_currency(range[:from].to_m) end if range[:from].present? && range[:to].present? result << ' - ' end if range[:to].blank? price = number_to_currency(range[:from].to_m) return t('workarea.facets.price_range.over', price: price).html_safe elsif range[:from].present? result << number_to_currency(range[:to].to_m) end result.html_safe end |