From e3f84ae9f84ff29f7a0437a632917fee6f3b50a3 Mon Sep 17 00:00:00 2001 From: Cory Lown Date: Fri, 3 May 2024 18:52:22 -0400 Subject: [PATCH] Use collection_id for linking rather than inferring from eadid --- app/components/arclight/collection_sidebar_component.rb | 4 +--- app/models/arclight/parents.rb | 2 +- app/models/concerns/arclight/solr_document.rb | 1 + spec/components/arclight/breadcrumb_component_spec.rb | 6 ++++-- .../arclight/collection_sidebar_component_spec.rb | 2 +- spec/models/arclight/parents_spec.rb | 2 ++ spec/models/concerns/arclight/solr_document_spec.rb | 1 + 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/components/arclight/collection_sidebar_component.rb b/app/components/arclight/collection_sidebar_component.rb index eeb460317..dcc4bbc37 100644 --- a/app/components/arclight/collection_sidebar_component.rb +++ b/app/components/arclight/collection_sidebar_component.rb @@ -29,13 +29,11 @@ def section_label(section) end def document_path - @document_path ||= solr_document_path(normalized_eadid) + @document_path ||= solr_document_path(document.collection_id) end def section_anchor(section) "##{t("arclight.views.show.sections.#{section}").parameterize}" end - - delegate :normalized_eadid, to: :document end end diff --git a/app/models/arclight/parents.rb b/app/models/arclight/parents.rb index c94b1456a..fe1f9b5e9 100644 --- a/app/models/arclight/parents.rb +++ b/app/models/arclight/parents.rb @@ -29,7 +29,7 @@ def as_parents # @param [SolrDocument] document def self.from_solr_document(document) ids = document.parent_ids - legacy_ids = document.legacy_parent_ids.map { |legacy_id| document.eadid == legacy_id ? legacy_id : "#{document.eadid}#{legacy_id}" } + legacy_ids = document.legacy_parent_ids.map { |legacy_id| document.collection_id == legacy_id ? legacy_id : "#{document.collection_id}#{legacy_id}" } labels = document.parent_labels eadid = document.eadid levels = document.parent_levels diff --git a/app/models/concerns/arclight/solr_document.rb b/app/models/concerns/arclight/solr_document.rb index e501d9d23..0917dd169 100644 --- a/app/models/concerns/arclight/solr_document.rb +++ b/app/models/concerns/arclight/solr_document.rb @@ -29,6 +29,7 @@ module SolrDocument attribute :total_component_count, :string, 'total_component_count_is' attribute :online_item_count, :string, 'online_item_count_is' attribute :last_indexed, :date, 'timestamp' + attribute :collection_id, :string, '_root_' end def repository_config diff --git a/spec/components/arclight/breadcrumb_component_spec.rb b/spec/components/arclight/breadcrumb_component_spec.rb index a55b1da60..ffae3666c 100644 --- a/spec/components/arclight/breadcrumb_component_spec.rb +++ b/spec/components/arclight/breadcrumb_component_spec.rb @@ -8,7 +8,8 @@ parent_ids_ssim: %w[abc123 abc123_def abc123_ghi], parent_unittitles_ssm: %w[ABC123 DEF GHI], ead_ssi: 'abc123', - repository_ssm: 'my repository' + repository_ssm: 'my repository', + _root_: 'abc123' ) end @@ -62,7 +63,8 @@ parent_ssim: %w[abc123 def ghi], parent_unittitles_ssm: %w[ABC123 DEF GHI], ead_ssi: 'abc123', - repository_ssm: 'my repository' + repository_ssm: 'my repository', + _root_: 'abc123' ) end diff --git a/spec/components/arclight/collection_sidebar_component_spec.rb b/spec/components/arclight/collection_sidebar_component_spec.rb index cdc72d875..9560d8062 100644 --- a/spec/components/arclight/collection_sidebar_component_spec.rb +++ b/spec/components/arclight/collection_sidebar_component_spec.rb @@ -13,7 +13,7 @@ render_inline(component) end - let(:document) { instance_double(SolrDocument, normalized_eadid: 'foo') } + let(:document) { instance_double(SolrDocument, collection_id: 'foo') } let(:collection_presenter) { instance_double(Arclight::ShowPresenter, with_field_group: group_presenter) } let(:group_presenter) { instance_double(Arclight::ShowPresenter, fields_to_render: [double]) } diff --git a/spec/models/arclight/parents_spec.rb b/spec/models/arclight/parents_spec.rb index dc2b1231d..6dfe50c17 100644 --- a/spec/models/arclight/parents_spec.rb +++ b/spec/models/arclight/parents_spec.rb @@ -8,6 +8,7 @@ parent_ids_ssim: %w[abc123 abc123_def abc123_ghi], parent_unittitles_ssm: %w[ABC123 DEF GHI], ead_ssi: 'abc123', + _root_: 'abc123', parent_levels_ssm: %w[collection] ) end @@ -17,6 +18,7 @@ parent_ssim: %w[abc123 def ghi], parent_unittitles_ssm: %w[ABC123 DEF GHI], ead_ssi: 'abc123', + _root_: 'abc123', parent_levels_ssm: %w[collection] ) end diff --git a/spec/models/concerns/arclight/solr_document_spec.rb b/spec/models/concerns/arclight/solr_document_spec.rb index d37127f55..a7bc5e406 100644 --- a/spec/models/concerns/arclight/solr_document_spec.rb +++ b/spec/models/concerns/arclight/solr_document_spec.rb @@ -10,6 +10,7 @@ it { expect(document).to respond_to(:parent_ids) } it { expect(document).to respond_to(:parent_labels) } it { expect(document).to respond_to(:eadid) } + it { expect(document).to respond_to(:collection_id) } end describe '#repository_config' do