Class: Blacklight::Hierarchy::FacetFieldListComponent
- Inherits:
-
FacetFieldListComponent
- Object
- FacetFieldListComponent
- Blacklight::Hierarchy::FacetFieldListComponent
- Defined in:
- app/components/blacklight/hierarchy/facet_field_list_component.rb
Constant Summary collapse
- DELIMITER =
'_'
Instance Method Summary collapse
- #field_name ⇒ Object
-
#prefix ⇒ String
then possible hkey values would be ‘wf’, ‘callnum_top’, and ‘exploded_tag’.
-
#tree ⇒ String
Html for the facet tree.
Instance Method Details
#field_name ⇒ Object
20 21 22 |
# File 'app/components/blacklight/hierarchy/facet_field_list_component.rb', line 20 def field_name @facet_field.facet_field.field end |
#prefix ⇒ String
then possible hkey values would be ‘wf’, ‘callnum_top’, and ‘exploded_tag’.
the key in the :hierarchy hash is the “prefix” for the solr field with the hierarchy info. the value
in the hash is a list, where the first element is a list of suffixes, and the second element is the delimiter
used to break up the sections of hierarchical data in the solr field being read. when joined, the prefix and
suffix should form the field name. so, for example, 'wf_wps', 'wf_wsp', 'wf_swp', 'callnum_top_facet', and
'exploded_tag_ssim' would be the solr fields with blacklight-hierarchy related configuration according to the
hash above. ':' would be the delimiter used in all of those fields except for 'callnum_top_facet', which would
use '/'. exploded_tag_ssim might contain values like ['Book', 'Book : Multi-Volume Work'], and callnum_top_facet
might contain values like ['LB', 'LB/2395', 'LB/2395/.C65', 'LB/2395/.C65/1991'].
note: the suffixes (e.g. ‘ssim’ for ‘exploded_tag’ in the above example) can’t have underscores, otherwise things break.
44 45 46 |
# File 'app/components/blacklight/hierarchy/facet_field_list_component.rb', line 44 def prefix @prefix ||= field_name.gsub("#{DELIMITER}#{field_name.split(/#{DELIMITER}/).last}", '') end |
#tree ⇒ String
Returns html for the facet tree.
10 11 12 13 14 15 16 17 18 |
# File 'app/components/blacklight/hierarchy/facet_field_list_component.rb', line 10 def tree @tree ||= begin facet_tree_for_prefix = FacetTree.build(prefix: prefix, facet_display: blacklight_config.facet_display, facet_field: @facet_field) facet_tree_for_prefix ? facet_tree_for_prefix[field_name] : nil end end |