Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify conditions for not showing the location request link #4006

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions app/policies/location_request_link_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?
Expand Down
Loading