Sha256: da0c09b74926ce093efe6fd5437be80c50cd66152c3056cad798933574283c7a

Contents?: true

Size: 962 Bytes

Versions: 4

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

module BlacklightRangeLimit
  class RangeFacetComponent < ::ViewComponent::Base
    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

4 entries across 4 versions & 1 rubygems

Version Path
blacklight_range_limit-8.2.3 app/components/blacklight_range_limit/range_facet_component.rb
blacklight_range_limit-8.2.2 app/components/blacklight_range_limit/range_facet_component.rb
blacklight_range_limit-8.2.1 app/components/blacklight_range_limit/range_facet_component.rb
blacklight_range_limit-8.2.0 app/components/blacklight_range_limit/range_facet_component.rb