Sha256: 9b861c9809417ce5705ff629310713b43a2246efd6a92e2e1705d3a124a4bed6

Contents?: true

Size: 813 Bytes

Versions: 15

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Hierarchy
    class FacetFieldComponent < ::ViewComponent::Base
      def initialize(field_name:, tree:, key:)
        @field_name = field_name
        @tree = tree
        @key = key
        @id = SecureRandom.uuid
      end

      attr_reader :field_name, :tree, :key, :id

      def subset
        @subset ||= tree.reject { |k, _v| !k.is_a?(String) }
      end

      def li_class
        subset.empty? ? 'h-leaf' : 'h-node'
      end

      def controller_name
        subset.empty? ? '' : 'b-h-collapsible'
      end


      def item
        tree[:_]
      end

      def qfacet_selected?
        config = helpers.facet_configuration_for_field(field_name)
        helpers.search_state.filter(config).include?(item.qvalue)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blacklight-hierarchy-6.4.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.3.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.2.2 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.2.1 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.2.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.1.2 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.1.1 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.1.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.0.2 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.0.1 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-6.0.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-5.4.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-5.3.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-5.2.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-5.1.0 app/components/blacklight/hierarchy/facet_field_component.rb