Sha256: 10e2d593b8ba22c8e1651ed7d1ba272575ce14c57288aa39aa5eb1617a23ac1f

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Arclight
  # Draw the links to the collection info in the sidebar
  class CollectionSidebarComponent < ViewComponent::Base
    def initialize(document:, partials:, collection_presenter:)
      super

      @document = document
      @partials = Array(partials)
      @collection_presenter = collection_presenter
    end

    attr_reader :document, :partials, :collection_presenter

    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

    def document_section_path(section)
      [document_path, section_anchor(section)].join
    end

    def section_label(section)
      t("arclight.views.show.sections.#{section}")
    end

    def document_path
      @document_path ||= solr_document_path(normalized_eadid)
    end

    def section_anchor(section)
      "##{t("arclight.views.show.sections.#{section}").parameterize}"
    end

    delegate :normalized_eadid, to: :document
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
arclight-1.1.3 app/components/arclight/collection_sidebar_component.rb
arclight-1.1.2 app/components/arclight/collection_sidebar_component.rb
arclight-1.1.1 app/components/arclight/collection_sidebar_component.rb
arclight-1.1.0 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.1 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.0 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.0.beta6 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.0.beta4 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.0.beta3 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.0.beta2 app/components/arclight/collection_sidebar_component.rb
arclight-1.0.0.beta1 app/components/arclight/collection_sidebar_component.rb