Class: Arclight::DocumentCollectionHierarchyComponent
- Inherits:
-
SearchResultComponent
- Object
- Blacklight::DocumentComponent
- SearchResultComponent
- Arclight::DocumentCollectionHierarchyComponent
- Defined in:
- app/components/arclight/document_collection_hierarchy_component.rb
Overview
Display a single document in the collection hierarchy
Instance Attribute Summary collapse
-
#blacklight_config ⇒ Object
readonly
Returns the value of attribute blacklight_config.
Attributes inherited from SearchResultComponent
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(document: nil, nest_path: nil, blacklight_config: nil, **kwargs) ⇒ DocumentCollectionHierarchyComponent
constructor
A new instance of DocumentCollectionHierarchyComponent.
-
#show_expanded? ⇒ Boolean
we want to eager-load this document’s children if we’re in the target document’s component hierarchy.
-
#target_index ⇒ String
Solr nest paths are constructed using the path name and an index, e.g.
Methods inherited from SearchResultComponent
Constructor Details
#initialize(document: nil, nest_path: nil, blacklight_config: nil, **kwargs) ⇒ DocumentCollectionHierarchyComponent
Returns a new instance of DocumentCollectionHierarchyComponent.
8 9 10 11 12 |
# File 'app/components/arclight/document_collection_hierarchy_component.rb', line 8 def initialize(document: nil, nest_path: nil, blacklight_config: nil, **kwargs) super(document: document, **kwargs) @nest_path = nest_path @blacklight_config = blacklight_config end |
Instance Attribute Details
#blacklight_config ⇒ Object (readonly)
Returns the value of attribute blacklight_config.
14 15 16 |
# File 'app/components/arclight/document_collection_hierarchy_component.rb', line 14 def blacklight_config @blacklight_config end |
Instance Method Details
#classes ⇒ Object
16 17 18 |
# File 'app/components/arclight/document_collection_hierarchy_component.rb', line 16 def classes super - ['row'] end |
#show_expanded? ⇒ Boolean
we want to eager-load this document’s children if we’re in the target document’s component hierarchy
22 23 24 |
# File 'app/components/arclight/document_collection_hierarchy_component.rb', line 22 def within_original_tree? end |
#target_index ⇒ String
Solr nest paths are constructed using the path name and an index, e.g. ‘/components#5/components#3`.
30 31 32 33 34 35 36 37 38 |
# File 'app/components/arclight/document_collection_hierarchy_component.rb', line 30 def target_index return -1 unless within_original_tree? remaining_path = nest_path.sub("#{@document.nest_path}/", '') current_component, _rest = remaining_path.split('/', 2) _name, index = current_component.split('#', 2) index&.to_i end |