Sha256: e87f3366708e384f14364d0c6059b0ad7b351622bda7cd9c1ac9065843b93633

Contents?: true

Size: 761 Bytes

Versions: 6

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module BlacklightRangeLimit
  class RangeSegmentsComponent < Blacklight::Component
    def initialize(facet_field:, facet_items: nil, item_component: nil, classes: [])
      super

      @facet_field = facet_field
      @facet_items = facet_items || facet_field.try(:range_queries) || []
      @item_component = facet_field.facet_field.item_component || Blacklight::FacetItemComponent
      @classes = classes
    end

    def facet_item_presenters
      @facet_items.map { |item| facet_item_presenter(item) }
    end

    def facet_item_presenter(facet_item)
      facet_config.item_presenter.new(facet_item, facet_config, helpers, @facet_field.key)
    end

    def facet_config
      @facet_field.facet_field
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight_range_limit-9.0.0 app/components/blacklight_range_limit/range_segments_component.rb
blacklight_range_limit-9.0.0.beta2 app/components/blacklight_range_limit/range_segments_component.rb
blacklight_range_limit-9.0.0.beta1 app/components/blacklight_range_limit/range_segments_component.rb
blacklight_range_limit-8.5.0 app/components/blacklight_range_limit/range_segments_component.rb
blacklight_range_limit-8.4.0 app/components/blacklight_range_limit/range_segments_component.rb
blacklight_range_limit-8.3.0 app/components/blacklight_range_limit/range_segments_component.rb