Skip to content

Commit

Permalink
Don't show stackmap link for reserves w/o maps
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkadel committed Mar 24, 2023
1 parent 19f27a9 commit 0def139
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
3 changes: 3 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ def holding_requests_adapter
# Currently this logic is duplicated in Javascript code in availability.es6
def find_it_location?(location_code)
return false if (location_code || "").start_with?("plasma$", "marquand$")

return false if StackmapService::Url.missing_stackmap_reserves.include?(location_code)

true
end

Expand Down
22 changes: 11 additions & 11 deletions app/services/stackmap_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def initialize(document:, loc:, cn: nil)
# @return [String] stackmap url
def url
if valid?
if missing_stackmap_reserves.include? @loc
missing_stackmap_reserves[@loc]
if StackmapService::Url.missing_stackmap_reserves.include? @loc
StackmapService::Url.missing_stackmap_reserves[@loc]
elsif stackmap_libs.include? lib
stackmap_url
else
Expand All @@ -42,6 +42,15 @@ def location_label
holding_location[:label].presence || holding_location[:library][:label]
end

def self.missing_stackmap_reserves
{
'arch$res3hr' => 'https://library.princeton.edu/architecture',
'stokes$respiapr' => 'https://library.princeton.edu/stokes',
'plasma$res' => 'https://library.princeton.edu/plasma-physics',
'lewis$gr' => 'https://library.princeton.edu/lewis'
}
end

private

def locator_url
Expand Down Expand Up @@ -82,15 +91,6 @@ def stackmap_libs
end
end

def missing_stackmap_reserves
{
'arch$res3hr' => 'https://library.princeton.edu/architecture',
'stokes$respiapr' => 'https://library.princeton.edu/stokes',
'plasma$res' => 'https://library.princeton.edu/plasma-physics',
'lewis$gr' => 'https://library.princeton.edu/lewis'
}
end

def by_title_locations
%w[lewis$serial plasma$ps stokes$sprps stokes$spiaps]
end
Expand Down
24 changes: 24 additions & 0 deletions spec/helpers/holding_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,23 @@
}.with_indifferent_access
end

let(:document_in_temp_reserve_location) do
{
id: '1',
format: ['Book'],
holdings_1display: {
"arch$res3hr": {
location_code: "arch$res3hr",
current_location: "Reserve 3-Hour",
current_library: "Architecture Library",
call_number: "HT166.I3",
call_number_browse: "HT166.I3",
temp_location_code: "arch$res3hr"
}
}.to_json.to_s
}.with_indifferent_access
end

before { stub_holding_locations }

context 'with Firestone Locator off' do
Expand Down Expand Up @@ -412,6 +429,13 @@
search_result = helper.holding_block_search(SolrDocument.new(document_without_find_it_link))
expect(search_result).not_to include "data-map-location"
end

context 'with a reserve item in a temporary location' do
it 'does not include the find it icon' do
search_result = helper.holding_block_search(SolrDocument.new(document_in_temp_reserve_location))
expect(search_result).not_to include "data-map-location"
end
end
end

context '#holding_block_search with links only' do
Expand Down

0 comments on commit 0def139

Please sign in to comment.