-
-
+
+
-
+
<%= t 'arclight.views.show.context' %>
<%= render Arclight::MetadataSectionComponent.with_collection(blacklight_config.show.metadata_partials || [], presenter: presenter, heading: true) %>
-
- <% end %>
+
-
' id='<%= document.collection? ? 'contents' : 'context' %>' role='tabpanel'>
-
><%= document.collection? ? t('arclight.views.show.has_content') : t('arclight.views.show.context') %>
- <%= content_tag(:div, id: document.collection? ? nil : t("arclight.views.show.sections.collection_context_field").parameterize) do %>
+
+
><%= t('arclight.views.show.has_content') %>
+ <%= content_tag(:div) do %>
<%= generic_context_navigation(@document) %>
<% end %>
@@ -106,7 +96,7 @@
name: document.collection_name,
access: 'online',
view: 'online_contents',
- parent: document.collection? ? nil : document.reference,
+ parent: nil,
search_field: 'within_collection'
}
}
@@ -117,11 +107,7 @@
<%= t 'arclight.views.show.access' %>
- <% if @document.collection? %>
- <%= render Arclight::MetadataSectionComponent.with_collection(blacklight_config.show.context_access_tab_items || [], presenter: presenter) %>
- <% else %>
- <%= render Arclight::MetadataSectionComponent.with_collection(blacklight_config.show.component_access_tab_items || [], presenter: presenter) %>
- <% end %>
+ <%= render Arclight::MetadataSectionComponent.with_collection(blacklight_config.show.context_access_tab_items || [], presenter: presenter) %>
diff --git a/app/components/arclight/collection_component.rb b/app/components/arclight/collection_component.rb
new file mode 100644
index 000000000..ba6b018e2
--- /dev/null
+++ b/app/components/arclight/collection_component.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Arclight
+ # Render a single collection document
+ class CollectionComponent < Blacklight::DocumentComponent
+ def blacklight_config
+ presenter.configuration
+ end
+ attr_reader :document
+
+ delegate :online_content?, to: :document
+ end
+end
diff --git a/app/components/arclight/document_component.rb b/app/components/arclight/document_component.rb
index 575c491af..8501887b6 100644
--- a/app/components/arclight/document_component.rb
+++ b/app/components/arclight/document_component.rb
@@ -3,14 +3,20 @@
module Arclight
# Render a single document
class DocumentComponent < Blacklight::DocumentComponent
- attr_reader :document
-
- def online_content?
- document.online_content? && (document.collection? || document.children?)
+ def initialize(presenter:, **kwargs) # rubocop:disable Lint/MissingSuper
+ @presenter = presenter
+ @kwargs = kwargs
end
- def blacklight_config
- presenter.configuration
+ attr_reader :presenter
+ delegate :collection?, to: :presenter
+
+ def call
+ if collection?
+ render CollectionComponent.new(presenter: presenter, **@kwargs)
+ else
+ render NonCollectionComponent.new(presenter: presenter, **@kwargs)
+ end
end
end
end
diff --git a/app/components/arclight/non_collection_component.html.erb b/app/components/arclight/non_collection_component.html.erb
new file mode 100644
index 000000000..bf10bb5b4
--- /dev/null
+++ b/app/components/arclight/non_collection_component.html.erb
@@ -0,0 +1,88 @@
+
+
+
+
+
+ <%= render Arclight::DocumentActionsComponent.new(presenter: presenter) %>
+
+
+<%= render Arclight::MetadataSectionComponent.with_collection(blacklight_config.show.component_metadata_partials || [], metadata_attr: { layout: Arclight::UpperMetadataLayoutComponent }, presenter: presenter, classes: ['al-metadata-section', 'breadcrumb-item', "breadcrumb-item-#{document.parents.length + 3}"]) %>
+
+
+
+
+
+
+
+
+
+
><%= t('arclight.views.show.context') %>
+ <%= content_tag(:div, id: t("arclight.views.show.sections.collection_context_field").parameterize) do %>
+ <%= generic_context_navigation(@document) %>
+ <% end %>
+
+
+ <% if online_content? %>
+
+
<%= t 'arclight.views.show.online_content' %>
+ <%= content_tag(
+ :div, '',
+ class: 'al-contents',
+ data: {
+ arclight: {
+ path: search_catalog_path,
+ name: document.collection_name,
+ access: 'online',
+ view: 'online_contents',
+ parent: document.reference,
+ search_field: 'within_collection'
+ }
+ }
+ ) %>
+
+ <% end %>
+
+
+
<%= t 'arclight.views.show.access' %>
+
+ <%= render Arclight::MetadataSectionComponent.with_collection(blacklight_config.show.component_access_tab_items || [], presenter: presenter) %>
+
+
+
+
diff --git a/app/components/arclight/non_collection_component.rb b/app/components/arclight/non_collection_component.rb
new file mode 100644
index 000000000..50ebaea2d
--- /dev/null
+++ b/app/components/arclight/non_collection_component.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module Arclight
+ # Render a single non-collection document
+ class NonCollectionComponent < Blacklight::DocumentComponent
+ attr_reader :document
+
+ def blacklight_config
+ presenter.configuration
+ end
+
+ def online_content?
+ document.online_content? && document.children?
+ end
+ end
+end
diff --git a/app/presenters/arclight/show_presenter.rb b/app/presenters/arclight/show_presenter.rb
index 1e2e651e6..8eaba28e1 100644
--- a/app/presenters/arclight/show_presenter.rb
+++ b/app/presenters/arclight/show_presenter.rb
@@ -4,6 +4,7 @@ module Arclight
# Custom presentation methods for show partial
class ShowPresenter < Blacklight::ShowPresenter
attr_accessor :field_group
+ delegate :collection?, to: :document
def heading
document.normalized_title