Class: Blacklight::Hierarchy::FacetFieldComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::Hierarchy::FacetFieldComponent
- Defined in:
- app/components/blacklight/hierarchy/facet_field_component.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
- #controller_name ⇒ Object
-
#initialize(field_name:, tree:, key:) ⇒ FacetFieldComponent
constructor
A new instance of FacetFieldComponent.
- #item ⇒ Object
- #li_class ⇒ Object
- #qfacet_selected? ⇒ Boolean
- #subset ⇒ Object
Constructor Details
#initialize(field_name:, tree:, key:) ⇒ FacetFieldComponent
Returns a new instance of FacetFieldComponent.
6 7 8 9 10 11 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 6 def initialize(field_name:, tree:, key:) @field_name = field_name @tree = tree @key = key @id = SecureRandom.uuid end |
Instance Attribute Details
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
13 14 15 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 13 def field_name @field_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 13 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
13 14 15 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 13 def key @key end |
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
13 14 15 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 13 def tree @tree end |
Instance Method Details
#controller_name ⇒ Object
23 24 25 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 23 def controller_name subset.empty? ? '' : 'b-h-collapsible' end |
#item ⇒ Object
28 29 30 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 28 def item tree[:_] end |
#li_class ⇒ Object
19 20 21 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 19 def li_class subset.empty? ? 'h-leaf' : 'h-node' end |
#qfacet_selected? ⇒ Boolean
32 33 34 35 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 32 def qfacet_selected? config = helpers.facet_configuration_for_field(field_name) helpers.search_state.filter(config).include?(item.qvalue) end |
#subset ⇒ Object
15 16 17 |
# File 'app/components/blacklight/hierarchy/facet_field_component.rb', line 15 def subset @subset ||= tree.reject { |k, _v| !k.is_a?(String) } end |