Class: Blacklight::Response::FacetGroupComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/response/facet_group_component.rb

Overview

Render a group of facet fields

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

reset_compiler!, sidecar_files, upstream_sidecar_files

Constructor Details

#initialize(id:, title: nil, body_classes: 'facets-collapse d-lg-block collapse accordion') ⇒ FacetGroupComponent

Returns a new instance of FacetGroupComponent.

Parameters:

  • id (String)

    a unique identifier for the group

  • title (String) (defaults to: nil)

    the title of the facet group section



11
12
13
14
15
16
17
# File 'app/components/blacklight/response/facet_group_component.rb', line 11

def initialize(id:, title: nil, body_classes: 'facets-collapse d-lg-block collapse accordion')
  @groupname = id
  @id = id ? "facets-#{id}" : 'facets'
  @title = title || I18n.t("blacklight.search.#{@id}.title")
  @panel_id = id ? "facet-panel-#{id}-collapse" : 'facet-panel-collapse'
  @body_classes = body_classes
end

Instance Attribute Details

#body_classesObject

Returns the value of attribute body_classes.



19
20
21
# File 'app/components/blacklight/response/facet_group_component.rb', line 19

def body_classes
  @body_classes
end

Instance Method Details

#button_componentObject



25
26
27
# File 'app/components/blacklight/response/facet_group_component.rb', line 25

def button_component
  Blacklight::Response::FacetToggleButtonComponent
end

#collapse_toggle_button(panel_id) ⇒ Object



21
22
23
# File 'app/components/blacklight/response/facet_group_component.rb', line 21

def collapse_toggle_button(panel_id)
  render button_component.new(panel_id: panel_id)
end

#render?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'app/components/blacklight/response/facet_group_component.rb', line 29

def render?
  # debugger
  body.present?
end