From 87d30f047b1661e80ebedad291c4bd3099279926 Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Mon, 5 Aug 2024 13:41:23 +0000 Subject: [PATCH] Bug 37141: (follow-up) Check for expired bookings when rendering bookings table We preserve the existing logic of this bug and add another case for when we just encounter expired bookings. In that case we render the fieldset without the 'filtered' class and determine the value of filter_expired in bookings.js by the class being set. --- .../intranet-tmpl/prog/en/includes/patron-detail-tabs.inc | 6 ++++++ koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc index d831c30673..c81430d1f5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-detail-tabs.inc @@ -31,6 +31,7 @@ [% END %] [% WRAPPER tab_item tabname="bookings" %] [% SET bookings_count = patron.bookings.filter_by_active.count %] + [% SET expired_bookings_count = patron.bookings.count - bookings_count %] Bookings ([% bookings_count || 0 | html %]) [% END %] [% END %] @@ -232,6 +233,11 @@ Show expired
+ [% ELSIF ( expired_bookings_count ) %] +
+ Hide expired +
+
[% ELSE %]

Patron has nothing booked.

[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js b/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js index 22af9db15c..75bdda54b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js +++ b/koha-tmpl/intranet-tmpl/prog/js/tables/bookings.js @@ -2,8 +2,10 @@ // Bookings var bookings_table; $(document).ready(function () { + // Determine whether we have a filtered list + let filter_expired = $("#expired_filter").hasClass('filtered'); + // Load bookings table on tab selection - let filter_expired = true; $("#bookings-tab").on("click", function () { let additional_filters = { patron_id: patron_borrowernumber, -- 2.46.0