Class: Blacklight::Hierarchy::QfacetValueComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/blacklight/hierarchy/qfacet_value_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_name:, item:, id: nil, suppress_link: false) ⇒ QfacetValueComponent

Returns a new instance of QfacetValueComponent.



6
7
8
9
10
11
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 6

def initialize(field_name:, item:, id: nil, suppress_link: false)
  @field_name = field_name
  @item = item
  @id = id
  @suppress_link = suppress_link
end

Instance Attribute Details

#field_nameObject (readonly)

Returns the value of attribute field_name.



13
14
15
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 13

def field_name
  @field_name
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 13

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



13
14
15
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 13

def item
  @item
end

Returns the value of attribute suppress_link.



13
14
15
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 13

def suppress_link
  @suppress_link
end

Instance Method Details

#path_for_facetObject



15
16
17
18
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 15

def path_for_facet
  facet_config = helpers.facet_configuration_for_field(field_name)
  Blacklight::FacetItemPresenter.new(item.qvalue, facet_config, helpers, field_name).href
end

#render_facet_countObject



20
21
22
23
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 20

def render_facet_count
  classes = "facet-count"
  ("span", t('blacklight.search.facets.count', number: number_with_delimiter(item.hits)), class: classes)
end