From ff6aa6a6f110f11c8181295732010e5d6d1cf6f6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 16 Dec 2021 01:59:50 +0000 Subject: [PATCH] Bug 29706: Hide items that cannot be held by default when placing hold on OPAC This patch adds a 'holdable' and 'unholdable' class to the rows of the table Additionally I rename the 'backgroundcolor' field to 'onloan' as that is what it contains. Note: Out of the box, there is no css associated with this class I add a div around the table to allow hiding the new buttons as well when optiuons are hidden It would be nice in the future to utilise a Koha table here, however, it is complicated by multi-holds To test: 1 - Add a number of items to a record, ensuring they belong to different libraries 2 - Set 'Default checkout, hold and return policy'->'Hold policy' to 'From home library' 3 - Sign in to opac and attempt to placehold on the record 4 - Click 'show more options' and 'a specificitem' 5 - Note holds table includes items that cannot be held 6 - Apply patch 7 - Reload holds page 8 - Note items that cannot be heldare hidden 9 - Click 'Show unholdable items' and note they appear 10 - Click 'Hide unholdable items' and veriofy they hide 11 - Test with multi holds Signed-off-by: The Minh Luong Signed-off-by: Jonathan Druart --- .../bootstrap/en/modules/opac-reserve.tt | 47 ++++++++++++++----- opac/opac-reserve.pl | 2 +- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt index 85eb71e4da0..b85c17ba9d2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt @@ -343,7 +343,8 @@ [% IF bibitemloo.itemholdable %] - +
+
@@ -369,21 +370,32 @@ + [% SET unholdable_items = 0 %] [% FOREACH itemLoo IN bibitemloo.itemLoop %] - - + [% END %] + + [% ELSE %] + + [% END %] + + [%# copynumber %] [% IF ( item_level_itypes ) %]
Select a specific item:
- [% IF ( itemLoo.available ) %] - - [% ELSE %] - + [% ELSE %] +
+ + [% ELSE %] + [% SET unholdable_items = 1 %] + [% IF ( itemLoo.onloan ) %] +
+ [% IF unholdable_items %] + + + [% END %] + [% END # / IF ( bibitemloo.itemholdable )%] @@ -492,6 +509,12 @@ } $(document).ready(function() { + + $(".toggle_unholdable").click(function(e){ + e.preventDefault(); + $(".unholdable").toggle(); + }); + $("#hold-request-form").preventDoubleFormSubmit(); var copiesRowId = null; var wasSpecific = false; @@ -579,8 +602,8 @@ // If the user is *allowed* to choose a specific item // The first one is preselected - $("table.copiesrow").each(function(){ - var id = suffixOf($(this).attr("id"), "_"); + $(".copiesrow table").each(function(){ + var id = suffixOf($(this).closest('div').attr("id"), "_"); select_first_available(id); }); diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index e8810650f75..7be38e25680 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -508,7 +508,7 @@ foreach my $biblioNum (@biblionumbers) { my $issue = Koha::Checkouts->find( { itemnumber => $itemNum } ); if ( $issue ) { $itemLoopIter->{dateDue} = output_pref({ dt => dt_from_string($issue->date_due, 'sql'), as_due_date => 1 }); - $itemLoopIter->{backgroundcolor} = 'onloan'; + $itemLoopIter->{onloan} = 'onloan'; } # checking reserve -- 2.25.1