Class: Arclight::CollectionSidebarComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/arclight/collection_sidebar_component.rb

Overview

Draw the links to the collection info in the sidebar

Instance Attribute Summary collapse

Instance Method Summary collapse

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_presenterObject (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

#documentObject (readonly)

Returns the value of attribute document.



14
15
16
# File 'app/components/arclight/collection_sidebar_component.rb', line 14

def document
  @document
end

#partialsObject (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_pathObject



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

Returns:

  • (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)
  t("arclight.views.show.sections.#{section}")
end