Sha256: 84ca580e55c1990ece68185af7a96a3051f32def03a9d9fac2c9e2eaab8b7917

Contents?: true

Size: 962 Bytes

Versions: 3

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

module BlacklightRangeLimit
  class RangeFacetComponent < Blacklight::Component
    renders_one :more_link, ->(key:, label:) do
      tag.div class: 'more_facets' do
        link_to t('blacklight.range_limit.view_larger', field_name: label),
          search_facet_path(id: key),
          data: { blacklight_modal: 'trigger' }
      end
    end

    delegate :search_action_path, :search_facet_path, to: :helpers

    def initialize(facet_field:, layout: nil, classes: BlacklightRangeLimit.classes)
      @facet_field = facet_field
      @layout = layout == false ? Blacklight::FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
      @classes = classes
    end

    def range_config
      @facet_field.range_config
    end

    def range_limit_url(options = {})
      helpers.main_app.url_for(@facet_field.search_state.to_h.merge(range_field: @facet_field.key, action: 'range_limit').merge(options))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight_range_limit-8.5.0 app/components/blacklight_range_limit/range_facet_component.rb
blacklight_range_limit-8.4.0 app/components/blacklight_range_limit/range_facet_component.rb
blacklight_range_limit-8.3.0 app/components/blacklight_range_limit/range_facet_component.rb