From cafe99717264121d462826b2ce594a145db9ec53 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 23 Oct 2024 13:08:22 +0100 Subject: [PATCH] Bug 37354: (QA follow-up) Reset periodPicker on rule change This patch clears the periodPicker values when the applied circulation rules change. This prevents selection of one booking period against one set of rules and then a change of item to an itemtype where different rules should apply but the old selected period remaining and thus 'rule breaking' being allowed. --- koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js index 8c0c0cebcb2..fbba43d976d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js +++ b/koha-tmpl/intranet-tmpl/prog/js/modals/place_booking.js @@ -156,6 +156,10 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { }, success: function (response) { let rules = response[0]; + let changed = + issueLength !== rules.issuelength || + renewalsAllowed !== rules.renewalsallowed || + renewalLength !== rules.renewalperiod; issueLength = rules.issuelength; renewalsAllowed = rules.renewalsallowed; renewalLength = rules.renewalperiod; @@ -163,6 +167,9 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { trailDays = rules.bookings_trail_period; // redraw pariodPicker taking selected item into account + if (changed) { + periodPicker.clear(); + } periodPicker.redraw(); // Enable flatpickr now we have data we need @@ -175,6 +182,7 @@ $("#placeBookingModal").on("show.bs.modal", function (e) { }, }); } else { + periodPicker.clear(); $("#period_fields :input").prop("disabled", true); } } -- 2.47.0