Class: Arclight::CollectionSidebarComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Arclight::CollectionSidebarComponent
- Defined in:
- app/components/arclight/collection_sidebar_component.rb
Overview
Draw the links to the collection info in the sidebar
Instance Attribute Summary collapse
-
#collection_presenter ⇒ Object
readonly
Returns the value of attribute collection_presenter.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#partials ⇒ Object
readonly
Returns the value of attribute partials.
Instance Method Summary collapse
- #document_path ⇒ Object
- #document_section_path(section) ⇒ Object
- #has_section?(section) ⇒ Boolean
-
#initialize(document:, partials:, collection_presenter:) ⇒ CollectionSidebarComponent
constructor
A new instance of CollectionSidebarComponent.
- #section_anchor(section) ⇒ Object
- #section_label(section) ⇒ Object
Constructor Details
#initialize(document:, partials:, collection_presenter:) ⇒ CollectionSidebarComponent
Returns a new instance of CollectionSidebarComponent.
6 7 8 9 10 11 12 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 6 def initialize(document:, partials:, collection_presenter:) super @document = document @partials = Array(partials) @collection_presenter = collection_presenter end |
Instance Attribute Details
#collection_presenter ⇒ Object (readonly)
Returns the value of attribute collection_presenter.
14 15 16 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 14 def collection_presenter @collection_presenter end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
14 15 16 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 14 def document @document end |
#partials ⇒ Object (readonly)
Returns the value of attribute partials.
14 15 16 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 14 def partials @partials end |
Instance Method Details
#document_path ⇒ Object
31 32 33 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 31 def document_path @document_path ||= solr_document_path(document.collection_id) end |
#document_section_path(section) ⇒ Object
23 24 25 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 23 def document_section_path(section) [document_path, section_anchor(section)].join end |
#has_section?(section) ⇒ Boolean
16 17 18 19 20 21 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 16 def has_section?(section) # Access field data comes from repositories.yml not from solr, so handle it in a different way. return true if section == :access_field collection_presenter.with_field_group(section).fields_to_render.any? end |
#section_anchor(section) ⇒ Object
35 36 37 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 35 def section_anchor(section) "##{t("arclight.views.show.sections.#{section}").parameterize}" end |
#section_label(section) ⇒ Object
27 28 29 |
# File 'app/components/arclight/collection_sidebar_component.rb', line 27 def section_label(section) t("arclight.views.show.sections.#{section}") end |