Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Related section at component level #1491

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/components/arclight/document_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@
</div>
<% end %>

<%= related %>

<%= access %>
4 changes: 4 additions & 0 deletions app/components/arclight/document_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def access
render (blacklight_config.show.access_component || Arclight::AccessComponent).new(presenter: presenter)
end

def related
render (blacklight_config.show.related || Arclight::RelatedComponent).new(presenter: presenter)
end

def toggle_sidebar
button_tag(t('arclight.views.show.toggle_sidebar'),
type: :button,
Expand Down
14 changes: 14 additions & 0 deletions app/components/arclight/related_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

<% related_content = capture do %>
<%= render Arclight::MetadataSectionComponent.with_collection(section_names,
metadata_attr: { layout: Arclight::UpperMetadataLayoutComponent },
presenter: presenter) %>
<% end %>

<% if related_content.present? %>
<div id="<%= t('arclight.views.show.sections.related_field').parameterize %>">
<h2 class="al-show-sub-heading"><%= t 'arclight.views.show.sections.related_field' %></h2>

<%= related_content %>
</div>
<% end %>
25 changes: 25 additions & 0 deletions app/components/arclight/related_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Arclight
# Render "related" information for a document
class RelatedComponent < ViewComponent::Base
def initialize(presenter:)
super
@show_config = presenter.configuration.show
@presenter = presenter
end

attr_reader :presenter, :show_config

delegate :collection?, to: :presenter

# @return Array<Symbol> a list of metadata section names
def section_names
return Array(collection_related_items) if collection?

Array(component_related_items)
end

delegate :collection_related_items, :component_related_items, to: :show_config
end
end
1 change: 1 addition & 0 deletions app/models/concerns/arclight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Catalog
Blacklight::Configuration.define_field_access :cite_field, Blacklight::Configuration::ShowField
Blacklight::Configuration.define_field_access :contact_field, Blacklight::Configuration::ShowField
Blacklight::Configuration.define_field_access :component_field, Blacklight::Configuration::ShowField
Blacklight::Configuration.define_field_access :component_related_field, Blacklight::Configuration::ShowField
Blacklight::Configuration.define_field_access :component_indexed_terms_field, Blacklight::Configuration::ShowField
Blacklight::Configuration.define_field_access :terms_field, Blacklight::Configuration::ShowField
Blacklight::Configuration.define_field_access :component_terms_field, Blacklight::Configuration::ShowField
Expand Down
12 changes: 11 additions & 1 deletion lib/generators/arclight/templates/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class CatalogController < ApplicationController
config.show.breadcrumb_component = Arclight::BreadcrumbsHierarchyComponent
config.show.embed_component = Arclight::EmbedComponent
config.show.access_component = Arclight::AccessComponent
config.show.related_component = Arclight::AccessComponent
config.show.online_status_component = Arclight::OnlineStatusIndicatorComponent
config.show.display_type_field = 'level_ssm'
# config.show.thumbnail_field = 'thumbnail_path_ss'
Expand Down Expand Up @@ -108,6 +109,10 @@ class CatalogController < ApplicationController
contact_field
]

config.show.component_related_items = %i[
component_related_field
]

##
# Compact index view
config.view.compact!
Expand Down Expand Up @@ -300,9 +305,9 @@ class CatalogController < ApplicationController
# Collection Show Page - Related Section
config.add_related_field 'relatedmaterial', field: 'relatedmaterial_html_tesm', helper_method: :render_html_tags
config.add_related_field 'separatedmaterial', field: 'separatedmaterial_html_tesm', helper_method: :render_html_tags
config.add_related_field 'originalsloc', field: 'originalsloc_html_tesm', helper_method: :render_html_tags
config.add_related_field 'otherfindaid', field: 'otherfindaid_html_tesm', helper_method: :render_html_tags
config.add_related_field 'altformavail', field: 'altformavail_html_tesm', helper_method: :render_html_tags
config.add_related_field 'originalsloc', field: 'originalsloc_html_tesm', helper_method: :render_html_tags
config.add_related_field 'odd', field: 'odd_html_tesim', helper_method: :render_html_tags

# Collection Show Page - Indexed Terms Section
Expand Down Expand Up @@ -373,6 +378,11 @@ class CatalogController < ApplicationController
last_word_connector: '<br/>'
}

# Component Show Page - Related Section
config.add_component_related_field 'relatedmaterial', field: 'relatedmaterial_html_tesm', helper_method: :render_html_tags
config.add_component_related_field 'separatedmaterial', field: 'separatedmaterial_html_tesm', helper_method: :render_html_tags
config.add_component_related_field 'originalsloc', field: 'originalsloc_html_tesm', helper_method: :render_html_tags

# =================
# ACCESS TAB FIELDS
# =================
Expand Down
2 changes: 1 addition & 1 deletion spec/features/collection_filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
click_button 'Search'

expect(page).to have_css('.constraint-value .filter-value', text: 'Alpha Omega Alpha Archives, 1894-1992')
expect(page).to have_css('.al-document-listings .document', count: 1) # has results
expect(page).to have_css('.al-document-listings .document', count: 2) # has results
end

it 'allows the user to choose to search all collections' do
Expand Down
18 changes: 18 additions & 0 deletions spec/fixtures/ead/nlm/alphaomegaalpha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,24 @@
</did>
</c>
<c id="aspace_e440da3c98ed7d64ef8179d56244f931" level="otherlevel">
<originalsloc>
<p>File contains photocopies of original still held by the donor.</p>
</originalsloc>
<separatedmaterial>
<p>Photographs and sound recordings have been transferred to the appropriate
custodial divisions of the Library where they are identified as part of these papers.
Among the sound recordings are the following broadcasts:</p>
<list>Example broadcast</list>
</separatedmaterial>
<separatedmaterial>
<p>Other papers of Alpha Omega, which relate chiefly to his early years
and public service in California, are held by the California State Archives in
Sacramento.</p>
</separatedmaterial>
<relatedmaterial>
<p>Records relating to the Alpha Omega Commission are held in the National
Archives and Records Administration.</p>
</relatedmaterial>
<did>
<unittitle>Constitution amendments - drafts,</unittitle>
<unitdate>n.d.</unitdate>
Expand Down