Sha256: a442e1ed97e45e3dae43e875cf14eb54904e92c654dd14a96a79dc0f7f104a61

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 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 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

2 entries across 2 versions & 1 rubygems

Version Path
blacklight-hierarchy-5.0.0 app/components/blacklight/hierarchy/facet_field_component.rb
blacklight-hierarchy-4.3.0 app/components/blacklight/hierarchy/facet_field_component.rb