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 Method Summary collapse

Methods inherited from Component

reset_compiler!, sidecar_files, upstream_sidecar_files

Constructor Details

#initialize(id:, title: nil) ⇒ 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
# File 'app/components/blacklight/response/facet_group_component.rb', line 11

def initialize(id:, title: nil)
  @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'
end

Instance Method Details

#button_componentObject



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

def button_component
  Blacklight::Response::FacetToggleButtonComponent
end

#collapse_toggle_button(panel_id) ⇒ Object



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

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

#render?Boolean

Returns:

  • (Boolean)


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

def render?
  body.present?
end