-
Notifications
You must be signed in to change notification settings - Fork 10
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
Bound with redesign #4070
Closed
Closed
Bound with redesign #4070
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 38 additions & 31 deletions
69
app/components/access_panels/location_item_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,42 @@ | ||
<%= tag.tr class: classes, data: { barcode: item.barcode } do %> | ||
<td class="callnumber"> | ||
<%= item.callnumber %> | ||
</td> | ||
<% if render_item_note? %> | ||
<td class="public-note"> | ||
<% if item.public_note.present? %> | ||
<div class='public-note note-highlight'>Note: <%= inject_line_break_opportunities item.public_note %></div> | ||
<% end %> | ||
</td> | ||
<% end %> | ||
<% if render_item_details? %> | ||
<td class="item-availability" data-update-status="<%= !has_in_process_availability_class? %>" data-live-lookup-id="<%= item.live_lookup_instance_id %>" data-status-target=".availability-icon" data-item-id="<%= item.live_lookup_item_id %>" <%= "data-request-url='#{helpers.request_url(document, library: item.library, location: item.effective_permanent_location_code, barcode: item.barcode)}'".html_safe if render_real_time_availability_request_link? %>> | ||
<span class="availability-icon-wrapper"> | ||
<i class="availability-icon <%= item.status.availability_class %>"></i> | ||
<span data-available-text="<%= t('searchworks.availability.available') %>" data-unavailable-text="<%= t('searchworks.availability.unavailable') %>" class='status-text'> | ||
<%= availability_text %> | ||
<%= tag.li class: classes, data: html_data do %> | ||
<div class="d-flex"> | ||
<div class="callnumber"> | ||
<%= item.callnumber %> | ||
</div> | ||
<% if render_item_details? %> | ||
<div class="item-availability" data-update-status="<%= !has_in_process_availability_class? %>" data-live-lookup-id="<%= item.live_lookup_instance_id %>" data-status-target=".availability-icon" data-item-id="<%= item.live_lookup_item_id %>" <%= "data-request-url='#{helpers.request_url(document, library: item.library, location: item.effective_permanent_location_code, barcode: item.barcode)}'".html_safe if render_real_time_availability_request_link? %>> | ||
<span class="availability-icon-wrapper"> | ||
<i class="availability-icon <%= item.status.availability_class %>"></i> | ||
<span data-available-text="<%= t('searchworks.availability.available') %>" data-unavailable-text="<%= t('searchworks.availability.unavailable') %>" class='status-text'> | ||
<%= availability_text %> | ||
</span> | ||
</span> | ||
</span> | ||
<span class="temporary-location"> | ||
<%= temporary_location_text %> | ||
</span> | ||
<% if item.on_reserve? %> | ||
<%= item.loan_period %> | ||
<% end %> | ||
<% if render_item_level_request_link? %> | ||
<span class="request-link"> | ||
<%= render item.request_link %> | ||
<span class="temporary-location"> | ||
<%= temporary_location_text %> | ||
</span> | ||
<% end %> | ||
</td> | ||
<% else %> | ||
<td></td> | ||
<% if item.on_reserve? %> | ||
<%= item.loan_period %> | ||
<% end %> | ||
<% if render_item_level_request_link? %> | ||
<span class="request-link"> | ||
<%= render item.request_link %> | ||
</span> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<div class="public-note"> | ||
<% if item.public_note.present? %> | ||
<div class='public-note note-highlight'>Note: <%= inject_line_break_opportunities item.public_note %></div> | ||
<% end %> | ||
</div> | ||
|
||
<% if bound_with_parent? %> | ||
<div class="bound-with p-2 mt-2"> | ||
<div class="bound-with-type">Bound and shelved with</div> | ||
<div class="bound-with-title"><%= link_to bound_with_title, solr_document_path(item.bound_with_hrid) %></div> | ||
<div class="bound-with-callnumber"><%= bound_with_callnumber %></div> | ||
</div> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/components/search_result/location_item_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<%= tag.tr class: classes, data: { barcode: item.barcode } do %> | ||
<td class="callnumber"> | ||
<%= item.callnumber %> | ||
</td> | ||
|
||
<% if render_item_details? %> | ||
<td class="item-availability" data-update-status="<%= !has_in_process_availability_class? %>" data-live-lookup-id="<%= item.live_lookup_instance_id %>" data-status-target=".availability-icon" data-item-id="<%= item.live_lookup_item_id %>" <%= "data-request-url='#{helpers.request_url(document, library: item.library, location: item.effective_permanent_location_code, barcode: item.barcode)}'".html_safe if render_real_time_availability_request_link? %>> | ||
<span class="availability-icon-wrapper"> | ||
<i class="availability-icon <%= item.status.availability_class %>"></i> | ||
<span data-available-text="<%= t('searchworks.availability.available') %>" data-unavailable-text="<%= t('searchworks.availability.unavailable') %>" class='status-text'> | ||
<%= availability_text %> | ||
</span> | ||
</span> | ||
<span class="temporary-location"> | ||
<%= temporary_location_text %> | ||
</span> | ||
<% if item.on_reserve? %> | ||
<%= item.loan_period %> | ||
<% end %> | ||
<% if render_item_level_request_link? %> | ||
<span class="request-link"> | ||
<%= render item.request_link %> | ||
</span> | ||
<% end %> | ||
</td> | ||
<% else %> | ||
<td></td> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
module SearchResult | ||
class LocationItemComponent < ViewComponent::Base | ||
with_collection_parameter :item | ||
attr_reader :item, :document, :classes | ||
|
||
def initialize(item:, document:, classes: nil, render_item_level_request_link: true) | ||
super | ||
|
||
@item = item | ||
@classes = classes | ||
@document = document | ||
@render_item_level_request_link = render_item_level_request_link | ||
end | ||
|
||
def availability_text | ||
item.status.status_text unless temporary_location_text | ||
end | ||
|
||
def temporary_location_text | ||
return if item.effective_location&.details&.key?('availabilityClass') || | ||
item.effective_location&.details&.key?('searchworksTreatTemporaryLocationAsPermanentLocation') || | ||
item.effective_permanent_location_code == item.temporary_location_code | ||
|
||
item.temporary_location&.name | ||
end | ||
|
||
def has_in_process_availability_class? | ||
availability_class = item.effective_location&.details&.dig('availabilityClass') | ||
availability_class.present? && availability_class == 'In_process' | ||
end | ||
|
||
def render_item_details? | ||
!item.suppressed? | ||
end | ||
|
||
def render_item_level_request_link? | ||
@render_item_level_request_link | ||
end | ||
|
||
def render_real_time_availability_request_link? | ||
# we're not rendering item-level request links (because e.g. there's already alocation level request link) | ||
return false unless render_item_level_request_link? | ||
|
||
# don't render unless item is requestable | ||
return false unless item.requestable? | ||
|
||
# non-circulating items don't need real time availability | ||
return false unless item.circulates? | ||
|
||
# items that definitely have an item-level request link at render time don't need real time availability | ||
return false if item.request_link.render? | ||
|
||
true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be repeating a lot of what is in module AccessPanels.LocationItemComponent. Is there a reason we have to repeat all the same code. Could we use inheritance or something along those lines to not repeat code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I believe the way to do that is by extracting a new class rather than forcing inheritance. I'm trying not to make this PR too challenging to review, thus I've avoided this at this time. Keep in mind that #4107 comes after this PR and will substantially change what is in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #4151 as a way to preemptively reduce the duplication.