Sha256: a322463510556b620c2b9dff79e5f9bb989e21ef2ab298595e610bca32264384

Contents?: true

Size: 1.31 KB

Versions: 62

Compression:

Stored size: 1.31 KB

Contents

module Workarea
  module FacetsHelper
    def facet_path(facet, value)
      link_params = facet.params_for(value)
      link_params[:only_path] = true
      url_for(link_params)
    end

    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

    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
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.26 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.45 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.25 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.23 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.44 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.22 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.43 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.21 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.42 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.20 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.41 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.19 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.40 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.18 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.39 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.17 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.38 app/helpers/workarea/facets_helper.rb
workarea-core-3.5.16 app/helpers/workarea/facets_helper.rb
workarea-core-3.4.37 app/helpers/workarea/facets_helper.rb