Class: Blacklight::Hierarchy::QfacetValueComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::Hierarchy::QfacetValueComponent
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_name ⇒ Object
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
|
#id ⇒ Object
Returns the value of attribute id.
13
14
15
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 13
def id
@id
end
|
#item ⇒ Object
Returns the value of attribute item.
13
14
15
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 13
def item
@item
end
|
#suppress_link ⇒ Object
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
#facet_config ⇒ Object
29
30
31
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 29
def facet_config
helpers.facet_configuration_for_field(field_name)
end
|
#facet_item_presenter_class ⇒ Object
41
42
43
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 41
def facet_item_presenter_class
hierarchy_config.dig(field_name_prefix)[2] || Blacklight::FacetItemPresenter
end
|
#field_name_prefix ⇒ Object
37
38
39
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 37
def field_name_prefix
@field_name_prefix ||= field_name.gsub("_#{field_name.split(/_/).last}", '')
end
|
#hierarchy_config ⇒ Object
33
34
35
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 33
def hierarchy_config
helpers.blacklight_config.facet_display[:hierarchy]
end
|
#label_value ⇒ Object
15
16
17
18
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 15
def label_value
return item.value if facet_item_presenter_class == Blacklight::FacetItemPresenter
facet_item_presenter_class.new(item.qvalue, facet_config, helpers, field_name).label
end
|
#path_for_facet ⇒ Object
20
21
22
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 20
def path_for_facet
facet_item_presenter_class.new(item.qvalue, facet_config, helpers, field_name).href
end
|
#render_facet_count ⇒ Object
24
25
26
27
|
# File 'app/components/blacklight/hierarchy/qfacet_value_component.rb', line 24
def render_facet_count
classes = "facet-count"
content_tag("span", t('blacklight.search.facets.count', number: number_with_delimiter(item.hits)), class: classes)
end
|