Class: Blacklight::Facets::ListComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::Facets::ListComponent
show all
- Defined in:
- app/components/blacklight/facets/list_component.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Component
reset_compiler!, sidecar_files, upstream_sidecar_files
Constructor Details
#initialize(facet_field:, classes: %w[facet-values list-unstyled],, role: nil, layout: nil) ⇒ ListComponent
Returns a new instance of ListComponent.
6
7
8
9
10
11
12
13
14
|
# File 'app/components/blacklight/facets/list_component.rb', line 6
def initialize(facet_field:,
classes: %w[facet-values list-unstyled],
role: nil,
layout: nil)
@facet_field = facet_field
@classes = classes
@role = role
@layout = layout == false ? Blacklight::Facets::NoLayoutComponent : Blacklight::Facets::FieldComponent
end
|
Instance Attribute Details
#classes ⇒ Object
Returns the value of attribute classes.
16
17
18
|
# File 'app/components/blacklight/facets/list_component.rb', line 16
def classes
@classes
end
|
#layout ⇒ Object
Returns the value of attribute layout.
16
17
18
|
# File 'app/components/blacklight/facets/list_component.rb', line 16
def layout
@layout
end
|
#role ⇒ Object
Returns the value of attribute role.
16
17
18
|
# File 'app/components/blacklight/facets/list_component.rb', line 16
def role
@role
end
|
Instance Method Details
#facet_config ⇒ Object
40
41
42
|
# File 'app/components/blacklight/facets/list_component.rb', line 40
def facet_config
@facet_field.facet_field
end
|
#facet_item_component_class ⇒ Object
36
37
38
|
# File 'app/components/blacklight/facets/list_component.rb', line 36
def facet_item_component_class
facet_config.item_component
end
|
#facet_item_presenter(facet_item) ⇒ Object
32
33
34
|
# File 'app/components/blacklight/facets/list_component.rb', line 32
def facet_item_presenter(facet_item)
facet_config.item_presenter.new(facet_item, facet_config, helpers, @facet_field.key)
end
|
#facet_item_presenters ⇒ Object
22
23
24
25
26
|
# File 'app/components/blacklight/facets/list_component.rb', line 22
def facet_item_presenters
@facet_field.paginator.items.map do |item|
facet_item_presenter(item)
end
end
|
#facet_items(wrapping_element: :li, **item_args) ⇒ Object
18
19
20
|
# File 'app/components/blacklight/facets/list_component.rb', line 18
def facet_items(wrapping_element: :li, **item_args)
facet_item_component_class.with_collection(facet_item_presenters, wrapping_element: wrapping_element, **item_args)
end
|
#render? ⇒ Boolean
28
29
30
|
# File 'app/components/blacklight/facets/list_component.rb', line 28
def render?
@facet_field.paginator&.items&.any?
end
|