From d3399916bc824b276ad368486c98f669f97daa98 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Thu, 22 Feb 2024 10:01:16 -0600 Subject: [PATCH] Simplify conditions for not showing the location request link We only need to look for the presence of a bound with holding to determine we shouldn't show the link Both "bound_with" with items and "bound_with" without items can be handled in the same way. See https://searchworks.stanford.edu/view/2279186.json (no items) and https://searchworks.stanford.edu/view/396229.json (has items) --- app/policies/location_request_link_policy.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/policies/location_request_link_policy.rb b/app/policies/location_request_link_policy.rb index 350359564..b1eb4a80b 100644 --- a/app/policies/location_request_link_policy.rb +++ b/app/policies/location_request_link_policy.rb @@ -7,7 +7,7 @@ def initialize(location:, library:, items:) end def show? - return false unless items.any? && !bound_with_or_analyzed_serial? + return false if items.none? || bound_with? folio_pageable? end @@ -20,11 +20,9 @@ def aeon_pageable? attr_reader :location, :library, :items - # 1. The item is "Bound-with" in folio (determined by holdingsType.name, e.g. a86041) - # 2. The item is a analyzed serial (determined by a SEE-OTHER folio location) - def bound_with_or_analyzed_serial? - (!folio_items? && items.first.document&.folio_holdings&.any?(&:bound_with?)) || - (folio_items? && items.any? { |item| item.effective_location&.see_other? }) + # @return [Bool] true if the item is a Bound-with child in folio + def bound_with? + items.first.document&.folio_holdings&.any?(&:bound_with?) end def folio_items?