Skip to content

Commit

Permalink
Merge pull request #991 from projectblacklight/982-bugfix-context-nav…
Browse files Browse the repository at this point in the history
…igation

Bugfix: context navigation fetches correct child components when clic…
  • Loading branch information
mejackreed authored Mar 9, 2020
2 parents 9f1c90c + 4d1cd15 commit 90f0196
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
20 changes: 16 additions & 4 deletions app/assets/javascripts/arclight/context_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,27 @@ class ContextNavigation {
this.data = this.el.data();
this.parentLi = this.el.parent();
this.eadid = this.data.arclight.eadid;
this.originalParents = originalParents || this.data.arclight.originalParents;
this.originalParents = originalParents; // let originalParents stay null
this.originalDocument = originalDocument || this.data.arclight.originalDocument;
this.ul = $('<ul class="al-context-nav-parent"></ul>');
}

// Gets the targetId to select, based off of parents and current level
get targetId() {
return `${this.eadid}${this.originalParents[this.data.arclight.level]}`;
if (this.originalParents && this.originalParents[this.data.arclight.level]) {
return `${this.eadid}${this.originalParents[this.data.arclight.level]}`;
}
return this.data.arclight.originalDocument;
}

get requestParent() {
// Cases where you're viewing a component page (use its ancestor trail)...
if (this.originalParents && this.originalParents[this.data.arclight.level - 1]) {
return this.originalParents[this.data.arclight.level - 1];
}
// Cases where there are no parents provided...
// 1) when on a top-level collection page
// 2) when +/- gets clicked
return this.data.arclight.originalDocument.replace(this.eadid, '');
}

Expand Down Expand Up @@ -353,7 +360,10 @@ class ContextNavigation {
if (!targetArea.data().resolved) {
targetArea.find('.context-navigator').each((i, ee) => {
const contextNavigation = new ContextNavigation(
ee, that.originalParents, that.originalDocument
// Send null for originalParents. We want to disregard the original
// component's ancestor trail and instead use the current ID as the
// parent in the query to populate the navigator.
ee, null, that.originalDocument
);
contextNavigation.getData();
});
Expand All @@ -368,7 +378,9 @@ class ContextNavigation {
*/
Blacklight.onLoad(function () {
$('.context-navigator').each(function (i, e) {
const contextNavigation = new ContextNavigation(e);
const contextNavigation = new ContextNavigation(
e, $(this).data('arclight').originalParents, $(this).data('arclight').originalDocument
);
contextNavigation.getData();
});
});
11 changes: 11 additions & 0 deletions spec/features/component_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@
end
end
end

context 'when on a deeply nested component' do
let(:doc_id) { 'aoa271aspace_6ea193f778e553ca9ea0d00a3e5a1891' }

it 'enables expanding nodes outside of own ancestor tree' do
within '#collection-context' do
find('#aoa271aspace_01daa89087641f7fc9dbd7a10d3f2da9 .al-toggle-view-children').click
expect(page).to have_css '.document-title-heading', text: 'Miscellaneous 1999'
end
end
end
end

describe 'access tab', js: true do
Expand Down
3 changes: 1 addition & 2 deletions spec/features/search_breadcrumb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
expect(page).to have_content 'Search results'
end
end
end
context 'on regular search results' do

it do
visit search_catalog_path f: { level_sim: ['Collection'] }, search_field: 'all_fields'
within '.al-search-breadcrumb' do
Expand Down
4 changes: 0 additions & 4 deletions spec/presenters/arclight/index_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
end

before do
expect(view_context).to receive_messages(
controller: instance_double('Controller', params: {}, session: {}),
default_document_index_view_type: 'index'
)
config.index.title_field = :normalized_title_ssm
end

Expand Down

0 comments on commit 90f0196

Please sign in to comment.