Sha256: 5262bd648a78be372e2b03e12e6a0d8b14dfb14f65cf67dbf3553a5edae22e1f

Contents?: true

Size: 890 Bytes

Versions: 14

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  class DropdownFacetFieldComponent < Blacklight::FacetFieldListComponent
    def facet_item_presenters
      return to_enum(:facet_item_presenters) unless block_given?

      @facet_field.paginator.items.each do |item|
        skipped = facet_config.skip_item&.call(item)

        yield facet_item_presenter(item) unless skipped

        item.items&.each do |subitem|
          yield facet_item_presenter(subitem.dup.tap { |i| i.fq = nil if skipped })
        end
      end
    end

    def facet_item_presenter(facet_item)
      config = facet_config(facet_item.field)

      (config.item_presenter || Blacklight::FacetItemPresenter).new(facet_item, config, helpers, facet_item.field)
    end

    def facet_config(key = nil)
      return @facet_field.facet_field if key.nil?

      helpers.blacklight_config.facet_fields[key]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.4 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.3 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.2 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.1 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.0 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.0.rc3 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.0.rc2 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-5.0.0.rc1 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-4.0.0 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-4.0.0.rc3 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-4.0.0.rc2 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-4.0.0.rc1 app/components/hyrax/dropdown_facet_field_component.rb
hyrax-4.0.0.beta2 app/components/hyrax/dropdown_facet_field_component.rb