Class: Blacklight::Facets::ListComponent

Inherits:
Component
  • Object
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:, role: nil, layout: nil) ⇒ ListComponent

Returns a new instance of ListComponent.



6
7
8
9
10
# File 'app/components/blacklight/facets/list_component.rb', line 6

def initialize(facet_field:, role: nil, layout: nil)
  @facet_field = facet_field
  @role = role
  @layout = layout == false ? Blacklight::Facets::NoLayoutComponent : Blacklight::Facets::FieldComponent
end

Instance Attribute Details

#layoutObject

Returns the value of attribute layout.



12
13
14
# File 'app/components/blacklight/facets/list_component.rb', line 12

def layout
  @layout
end

#roleObject

Returns the value of attribute role.



12
13
14
# File 'app/components/blacklight/facets/list_component.rb', line 12

def role
  @role
end

Instance Method Details

#facet_configObject



36
37
38
# File 'app/components/blacklight/facets/list_component.rb', line 36

def facet_config
  @facet_field.facet_field
end

#facet_item_component_classObject



32
33
34
# File 'app/components/blacklight/facets/list_component.rb', line 32

def facet_item_component_class
  facet_config.item_component
end

#facet_item_presenter(facet_item) ⇒ Object



28
29
30
# File 'app/components/blacklight/facets/list_component.rb', line 28

def facet_item_presenter(facet_item)
  facet_config.item_presenter.new(facet_item, facet_config, helpers, @facet_field.key)
end

#facet_item_presentersObject



18
19
20
21
22
# File 'app/components/blacklight/facets/list_component.rb', line 18

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



14
15
16
# File 'app/components/blacklight/facets/list_component.rb', line 14

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

Returns:

  • (Boolean)


24
25
26
# File 'app/components/blacklight/facets/list_component.rb', line 24

def render?
  @facet_field.paginator&.items&.any?
end