From 9288a47b9701bed26b8259c3c01a3aaf0145ca33 Mon Sep 17 00:00:00 2001 From: CEdwardsBlasikiewicz Date: Fri, 10 May 2024 11:31:15 +1000 Subject: [PATCH 1/6] update display of "Guide to..." to only show on collection-level items. --- .../arclight/document_component.html.erb | 6 +++- .../breadcrumbs_hierarchy_component.html.erb | 34 +++++++++++++++++++ .../breadcrumbs_hierarchy_component.rb | 4 +++ app/controllers/catalog_controller.rb | 2 +- app/presenters/show_presenter.rb | 7 +++- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 app/components/breadcrumbs_hierarchy_component.html.erb create mode 100644 app/components/breadcrumbs_hierarchy_component.rb diff --git a/app/components/arclight/document_component.html.erb b/app/components/arclight/document_component.html.erb index 0e2616d6..22eac7fc 100644 --- a/app/components/arclight/document_component.html.erb +++ b/app/components/arclight/document_component.html.erb @@ -8,7 +8,11 @@
<%= content_tag :h1 do %> - <%= t('collection_prefix') + document.normalized_title %> + <% if document.collection? %> + <%= t('collection_prefix') + document.normalized_title %> + <% else %> + <%= document.normalized_title %> + <% end %> <% end %> <%= render 'arclight/requests', document: document %> <%= render Arclight::BookmarkComponent.new document: document, action: bookmark_config %> diff --git a/app/components/breadcrumbs_hierarchy_component.html.erb b/app/components/breadcrumbs_hierarchy_component.html.erb new file mode 100644 index 00000000..c005f55b --- /dev/null +++ b/app/components/breadcrumbs_hierarchy_component.html.erb @@ -0,0 +1,34 @@ + diff --git a/app/components/breadcrumbs_hierarchy_component.rb b/app/components/breadcrumbs_hierarchy_component.rb new file mode 100644 index 00000000..dac4a559 --- /dev/null +++ b/app/components/breadcrumbs_hierarchy_component.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class BreadcrumbsHierarchyComponent < Arclight::BreadcrumbsHierarchyComponent +end \ No newline at end of file diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 2d3590d3..1c555c75 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -96,7 +96,7 @@ class CatalogController < ApplicationController # config.show.title_field = 'title_display' config.show.document_component = Arclight::DocumentComponent config.show.sidebar_component = Arclight::SidebarComponent - config.show.breadcrumb_component = Arclight::BreadcrumbsHierarchyComponent + config.show.breadcrumb_component = BreadcrumbsHierarchyComponent config.show.embed_component = Arclight::EmbedComponent config.show.access_component = Arclight::AccessComponent config.show.online_status_component = Arclight::OnlineStatusIndicatorComponent diff --git a/app/presenters/show_presenter.rb b/app/presenters/show_presenter.rb index 3f879f6e..c5ed9289 100644 --- a/app/presenters/show_presenter.rb +++ b/app/presenters/show_presenter.rb @@ -2,6 +2,11 @@ class ShowPresenter < Arclight::ShowPresenter def heading - I18n.t("collection_prefix") + document.normalized_title + if document.collection? + I18n.t("collection_prefix") + document.normalized_title + else + document.normalized_title + end + end end From d7342ce2f33750bc5b26b03ab1f436709e606e7e Mon Sep 17 00:00:00 2001 From: CEdwardsBlasikiewicz Date: Fri, 10 May 2024 15:10:42 +1000 Subject: [PATCH 2/6] update display of "Guide to..." to only show on collection-level items. --- .../breadcrumbs_hierarchy_component.rb | 2 +- app/presenters/show_presenter.rb | 1 - .../arclight/breadcrumb_component_spec.rb | 74 +++++++++++++++++ spec/features/document_component_spec.rb | 67 +++++++++++----- spec/files/solr/367300335367601811.json | 80 +++++++++++++++++++ 5 files changed, 200 insertions(+), 24 deletions(-) create mode 100644 spec/components/arclight/breadcrumb_component_spec.rb create mode 100644 spec/files/solr/367300335367601811.json diff --git a/app/components/breadcrumbs_hierarchy_component.rb b/app/components/breadcrumbs_hierarchy_component.rb index dac4a559..5f1a6f45 100644 --- a/app/components/breadcrumbs_hierarchy_component.rb +++ b/app/components/breadcrumbs_hierarchy_component.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true class BreadcrumbsHierarchyComponent < Arclight::BreadcrumbsHierarchyComponent -end \ No newline at end of file +end diff --git a/app/presenters/show_presenter.rb b/app/presenters/show_presenter.rb index c5ed9289..401692a0 100644 --- a/app/presenters/show_presenter.rb +++ b/app/presenters/show_presenter.rb @@ -7,6 +7,5 @@ def heading else document.normalized_title end - end end diff --git a/spec/components/arclight/breadcrumb_component_spec.rb b/spec/components/arclight/breadcrumb_component_spec.rb new file mode 100644 index 00000000..5947f689 --- /dev/null +++ b/spec/components/arclight/breadcrumb_component_spec.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +require "rails_helper" + +RSpec.describe Arclight::BreadcrumbComponent, type: :component do + let(:document) do + SolrDocument.new( + parent_ids_ssim: %w[abc123 abc123_def abc123_ghi], + parent_unittitles_ssm: %w[ABC123 DEF GHI], + ead_ssi: "abc123", + repository_ssm: "my repository", + _root_: "abc123" + ) + end + + let(:render) do + component.render_in(vc_test_controller.view_context) + end + + let(:rendered) do + Capybara::Node::Simple.new(render) + end + + let(:component) { described_class.new(document: document) } + + context "with a count" do + it "renders only that many breadcrumb links" do + expect(rendered).to have_css "li", text: "my repository" + expect(rendered).to have_link "ABC123", href: "/catalog/abc123" + expect(rendered).not_to have_link "DEF", href: "/catalog/abc123_def" + expect(rendered).not_to have_link "GHI", href: "/catalog/abc123_ghi" + end + + it "renders an ellipsis if there are more links than the count" do + expect(render).to end_with ">…" + end + end + + context "with an offset" do + let(:attr) { {offset: 2} } + + it "skips some breadcrumb links" do + expect(rendered).not_to have_css "li", text: "my repository" + expect(rendered).not_to have_link "ABC123", href: "/catalog/abc123" + expect(rendered).to have_link "DEF", href: "/catalog/abc123_def" + expect(rendered).to have_link "GHI", href: "/catalog/abc123_ghi" + end + end + + it "renders breadcrumb links" do + expect(rendered).to have_css "li", text: "my repository" + expect(rendered).to have_link "DEF", href: "/catalog/abc123_def" + expect(rendered).to have_link "GHI", href: "/catalog/abc123_ghi" + end + + context "with legacy parent_ssm data" do + let(:legacy_document) do + SolrDocument.new( + parent_ssim: %w[abc123 def ghi], + parent_unittitles_ssm: %w[ABC123 DEF GHI], + ead_ssi: "abc123", + repository_ssm: "my repository", + _root_: "abc123" + ) + end + + let(:component) { described_class.new(document: legacy_document, **attr) } + + it "renders breadcrumb links" do + expect(rendered).to have_link "DEF", href: "/catalog/abc123def" + expect(rendered).to have_link "GHI", href: "/catalog/abc123ghi" + end + end +end diff --git a/spec/features/document_component_spec.rb b/spec/features/document_component_spec.rb index 627fce78..31ccb1b4 100644 --- a/spec/features/document_component_spec.rb +++ b/spec/features/document_component_spec.rb @@ -1,34 +1,57 @@ require "rails_helper" RSpec.describe "Document components" do - before do - solr_response = IO.read("spec/files/solr/280011976.json") - - WebMock.stub_request(:get, /solr:8983/) - .with( - headers: { - "Accept" => "*/*", - "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" - } - ) - .to_return(status: 200, body: solr_response, headers: {}) + context "at the collection level" do + before do + solr_response = IO.read("spec/files/solr/280011976.json") + + WebMock.stub_request(:get, /solr:8983/) + .with( + headers: { + "Accept" => "*/*", + "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + } + ) + .to_return(status: 200, body: solr_response, headers: {}) + end + + it "has correct tab title, including the collection prefix" do + visit solr_document_path(id: "280011976") + + expect(page).to have_title(I18n.t("collection_prefix") + "19th century currency items, c1868-1895 - Finding Aids") + end + + it "has correct title, including the collection prefix" do + visit solr_document_path(id: "280011976") + + expect(page).to have_css("div.title-container h1", text: I18n.t("collection_prefix") + "19th century currency items, c1868-1895") + end end - it "has correct tab title, including the collection prefix" do - visit solr_document_path(id: "280011976") + context "at the item level" do + before do + solr_response = IO.read("spec/files/solr/367300335367601811.json") - expect(page).to have_title(I18n.t("collection_prefix") + "19th century currency items, c1868-1895 - Finding Aids") - end + WebMock.stub_request(:get, /solr:8983/) + .with( + headers: { + "Accept" => "*/*", + "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" + } + ) + .to_return(status: 200, body: solr_response, headers: {}) + end - it "has correct breadcrumbs, including the collection prefix" do - visit solr_document_path(id: "280011976") + it "has correct tab title, excluding the collection prefix" do + visit solr_document_path(id: "367300335367601811") - expect(page).to have_css("span.breadcrumb-text", text: I18n.t("collection_prefix") + "19th century currency items, c1868-1895") - end + expect(page).to have_title("Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated") + end - it "has correct title, including the collection prefix" do - visit solr_document_path(id: "280011976") + it "has correct title, excluding the collection prefix" do + visit solr_document_path(id: "367300335367601811") - expect(page).to have_css("div.title-container h1", text: I18n.t("collection_prefix") + "19th century currency items, c1868-1895") + expect(page).to have_css("div.title-container h1", text: "Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated") + end end end diff --git a/spec/files/solr/367300335367601811.json b/spec/files/solr/367300335367601811.json new file mode 100644 index 00000000..f1c1e646 --- /dev/null +++ b/spec/files/solr/367300335367601811.json @@ -0,0 +1,80 @@ +{ + "responseHeader":{ + "zkConnected":true, + "status":0, + "QTime":1, + "params":{ + "q":"id:367300335367601811", + "fl":"*", + "_forwardedCount":"1", + "wt":"json"}}, + "response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[ + { + "id":"367300335367601811", + "fav_obj_id_ssi":"nla.obj-367710222", + "ref_ssi":"367601811", + "ref_ssm":["367601811"], + "component_level_isim":[2], + "sort_isi":2, + "bibid_ssi":"538326", + "folio_instance_id_ssi":"2ff67ac1-fd2b-515c-ba93-248652d934c0", + "parent_ssi":"367601771", + "aspace_id_ssi":"aspace_8cf2270ccfec1a6513579cb137066c2f", + "title_ssm":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated"], + "title_tesim":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated"], + "normalized_title_ssm":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated"], + "text":["Diaries, 1929, 1934; loose diary pages, 1916, 1929, 1930, 1935 and undated", + "1", + "Braga, J.M. (José Maria)", + "History"], + "parent_ssim":["367300335", + "367601771"], + "parent_levels_ssm":["collection", + "Series"], + "parent_unittitles_ssm":["Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)", + "Diaries and notebooks, 1916-c.1972"], + "parent_unittitles_tesim":["Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)", + "Diaries and notebooks, 1916-c.1972"], + "collection_ssim":["Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)"], + "unitid_ssm":["1"], + "ead_unitid_ssm":["367300335"], + "repository_ssim":["National Library of Australia"], + "collection_creator_ssm":["Braga, J.M. (José Maria)"], + "has_online_content_ssim":["false"], + "child_component_count_isi":0, + "level_ssim":["File"], + "level_ssm":["File"], + "parent_access_restrict_tesm":["Available for research."], + "parent_access_terms_tesm":["Copying and publishing of unpublished manuscript material is subject to copyright restrictions. For such material, written permission to publish must be obtained from the copyright holder(s). Copying of unpublished material for research purposes is permissible 50 years after the death of the creator of the material."], + "names_ssim":["Braga, J.M. (José Maria)"], + "access_subjects_ssim":["History"], + "access_subjects_ssm":["History"], + "acqinfo_ssim":["The bulk of the Braga Collection (including manuscripts, pictures, maps, newspapers, serials, periodicals, monographs and ephemera) was purchased from J.M. Braga in 1966. The component held in the Manuscript Collection at MS 4300 appears to have been formally accessioned as the J.M. Braga Papers in 1975. Several small additions have been made since the original instalment of papers was received. Most of these additions were transfers to the Manuscripts Collection from other collection areas, including a file of newspaper cuttings in May 1975, a set of microfilm reels in 1984, a file of manuscript material in 1985, lists of the Braga Collection in 1994, and two files of assorted printed material and other papers in 2009. As well, several small additions have been made by members of the Braga family. In 1992, various Braga family members donated a copy of the eulogy and order of service for Augusta Braga's memorial service, and in 2002 Angela Braga donated photographs of medals and decorations awarded to J.P. Braga, together with photocopies of early writings of J.M. Braga and eulogies for J.M. Braga and his grandson Michael Braga."], + "_nest_path_":"/child#0/child#0", + "_nest_parent_":"367300335367601771", + "_root_":"367300335", + "_version_":1796736391573405696, + "timestamp":"2024-04-19T04:35:49.969Z"}] + }, + "facet_counts":{ + "facet_queries":{}, + "facet_fields":{ + "level_ssim":[ + "File",1], + "creator_ssim":[], + "date_range_ssim":[], + "names_ssim":[ + "Braga, J.M. (José Maria)",1], + "geogname_ssim":[], + "access_subjects_ssim":[ + "History",1], + "repository_ssim":[ + "National Library of Australia",1], + "collection_ssim":[ + "Papers of J.M. Braga, 1862-2000 (bulk 1920-1971)",1]}, + "facet_ranges":{}, + "facet_intervals":{}, + "facet_heatmaps":{}}, + "spellcheck":{ + "suggestions":[], + "correctlySpelled":true}} \ No newline at end of file From 3bb54aa1c578460b5228d24c3eb542220d3fd7bc Mon Sep 17 00:00:00 2001 From: Yetrina Battad Date: Fri, 10 May 2024 18:11:14 +1000 Subject: [PATCH 3/6] test: fix specs for BreadcrumbsHierarchyComponent --- .../breadcrumbs_hierarchy_component.html.erb | 10 +-- .../arclight/breadcrumb_component_spec.rb | 74 ---------------- .../breadcrumbs_hierarchy_component_spec.rb | 88 +++++++++++++++++++ spec/features/document_component_spec.rb | 29 +----- 4 files changed, 94 insertions(+), 107 deletions(-) delete mode 100644 spec/components/arclight/breadcrumb_component_spec.rb create mode 100644 spec/components/arclight/breadcrumbs_hierarchy_component_spec.rb diff --git a/app/components/breadcrumbs_hierarchy_component.html.erb b/app/components/breadcrumbs_hierarchy_component.html.erb index c005f55b..845a29fb 100644 --- a/app/components/breadcrumbs_hierarchy_component.html.erb +++ b/app/components/breadcrumbs_hierarchy_component.html.erb @@ -1,15 +1,15 @@