Skip to content

Commit

Permalink
Merge pull request #4425 from pulibrary/3960-holdings-button-search-r…
Browse files Browse the repository at this point in the history
…esults

[#3960] Update holding block in search results to have the same
  • Loading branch information
christinach authored Oct 7, 2024
2 parents 78982e5 + d3d9a4b commit e3143b9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
16 changes: 3 additions & 13 deletions app/helpers/holdings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ def holding_block_search(document)
block << content_tag(:li, cdl_placeholder)
end

if @scsb_multiple == true
block << controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))

if @scsb_multiple == true || holdings_hash.length > 2
block << view_record_for_full_avail_li(document)
elsif holdings_hash.length > 2
block << additional_holdings_span
elsif !holdings_hash.empty?
block << view_record_for_full_avail_li_two(document)
end

block << controller.view_context.render(Holdings::OnlineHoldingsComponent.new(document:))

if block.empty?
content_tag(:div, t('blacklight.holdings.search_missing'))
else
Expand Down Expand Up @@ -191,13 +189,5 @@ def view_record_for_full_avail_li_two(document)
data: { record_id: document['id'] }
)
end

def additional_holdings_span
content_tag(
:span,
"View record for information on additional holdings",
"style": "font-size: small; font-style: italic;"
)
end
end
# rubocop:enable Metrics/ModuleLength
18 changes: 5 additions & 13 deletions spec/helpers/holding_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@
before { stub_holding_locations }

it 'displays View Record for Availability' do
expect(search_result).to include 'View record for information on additional holdings'
expect(search_result).to include 'View Record for Full Availability'
end
end
context '#holding_block_search' do
before { stub_holding_locations }
let(:expected_result) do
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><span style=\"font-size: small; font-style: italic;\">View record for information on additional holdings</span></ul>"
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li><a class=\"availability-icon badge badge-secondary more-info\" href=\"/catalog/1\">View Record for Full Availability</a></li></ul>"
end
it 'matches the expected result' do
expect(search_result).to eq(expected_result)
Expand Down Expand Up @@ -293,15 +293,7 @@
before { stub_holding_locations }
let(:expected_result) do
<<~END_RESULT.strip
<ul><li class="holding-status" data-availability-record="true" data-record-id="1" data-holding-id="3580281" data-bound-with="false"><span class="availability-icon badge badge-secondary">Loading...</span><div class="library-location" data-location="true" data-record-id="1" data-holding-id="3580281"><span class="results_location">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class="call-number">PS3539.A74Z93 2000</span></div></li><li><span class="badge badge-primary" data-availability-cdl="true"></span></li><li>
<span class="availability-icon badge badge-primary">Online</span>
<div class="library-location"><a target="_blank" rel="noopener" href="https://library.princeton.edu/resource/28076">library.princeton.edu</a></div>
</li>
<li><span class="badge badge-primary" data-availability-cdl="true"></span></li><span style="font-size: small; font-style: italic;">View record for information on additional holdings</span><li>
<span class="availability-icon badge badge-primary">Online</span>
<div class="library-location"><a target="_blank" rel="noopener" href="https://library.princeton.edu/resource/28076">library.princeton.edu</a></div>
</li>
</ul>
<ul><li class="holding-status" data-availability-record="true" data-record-id="1" data-holding-id="3580281" data-bound-with="false"><span class="availability-icon badge badge-secondary">Loading...</span><div class="library-location" data-location="true" data-record-id="1" data-holding-id="3580281"><span class="results_location">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class="call-number">PS3539.A74Z93 2000</span></div></li><li><span class="badge badge-primary" data-availability-cdl="true"></span></li><li>\n <span class="availability-icon badge badge-primary">Online</span>\n <div class="library-location"><a target="_blank" rel="noopener" href="https://library.princeton.edu/resource/28076">library.princeton.edu</a></div>\n</li>\n<li><span class="badge badge-primary" data-availability-cdl="true"></span></li><li>\n <span class="availability-icon badge badge-primary">Online</span>\n <div class="library-location"><a target="_blank" rel="noopener" href="https://library.princeton.edu/resource/28076">library.princeton.edu</a></div>\n</li>\n<li><a class="availability-icon badge badge-secondary more-info" href="/catalog/1">View Record for Full Availability</a></li></ul>
END_RESULT
end
it 'matches the expected result' do
Expand Down Expand Up @@ -400,7 +392,7 @@

context 'using the stackmap' do
let(:expected_result) do
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><span style=\"font-size: small; font-style: italic;\">View record for information on additional holdings</span></ul>"
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li><a class=\"availability-icon badge badge-secondary more-info\" href=\"/catalog/1\">View Record for Full Availability</a></li></ul>"
end
it 'matches the expected result' do
expect(search_result).to eq(expected_result)
Expand Down Expand Up @@ -492,7 +484,7 @@
context '#holding_block_search with embargoed thesis' do
before { stub_holding_locations }
let(:expected_result) do
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><span style=\"font-size: small; font-style: italic;\">View record for information on additional holdings</span></ul>"
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li><a class=\"availability-icon badge badge-secondary more-info\" href=\"/catalog/1\">View Record for Full Availability</a></li></ul>"
end
it 'matches the expected result' do
expect(search_result).to eq(expected_result)
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
r = JSON.parse(response.body)
expect(r['location'].length).to be > 2
get '/catalog?&search_field=all_fields&q=998574693506421'
expect(response.body).to include '<span style="font-size: small; font-style: italic;">View record for information on additional holdings</span>'
expect(response.body).to include 'View Record for Full Availability'
end
it 'displays the location name for an item with a single location' do
get '/catalog/993213506421/raw'
Expand Down

0 comments on commit e3143b9

Please sign in to comment.