From 6f8108852e54ba30670e64b3370c548f45d121b3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 4 Nov 2022 15:00:54 +0100 Subject: [PATCH] Bug 31262: Curbside pickup - Remove day without slots We disable dates from the date picker that do not have slots defined in the configuration. Note that dates that have slots configured but none are available will still be displayed. To implement that we would need to calculate the availability for all the dates displayed on the widget (1 month) and that will (certainly) slow down considerabily the UI. Test plan: Configure curbside pickup for a given library. Define slots for several days of the week (not all). Schedule a pickup and confirm that only the days with slots defined are available in the date picker widget Sponsored-by: Association KohaLa - https://koha-fr.org/ Signed-off-by: David Nind --- .../prog/en/modules/circ/curbside_pickups.tt | 8 ++++++++ .../bootstrap/en/modules/opac-curbside-pickups.tt | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt index 62bb1c2b0e..e61afed1c6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/curbside_pickups.tt @@ -547,6 +547,14 @@ $('#input-patron-cardnumber').focus(); }); + const pickup_date = document.querySelector("#pickup_date"); + if ( pickup_date ) { + const fp = pickup_date._flatpickr; + fp.set('disable', [function(date) { + return !slots_per_day.hasOwnProperty(date.getDay()); + }]); + } + $("#pickup_date").on('change', function() { $('#pickup-times').empty(); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt index 3760c79b30..ca1e1cd12e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-curbside-pickups.tt @@ -352,8 +352,11 @@ } }); - const pickupDate = document.getElementById("pickup-date"); - pickupDate._flatpickr.config.onClose.push(function( selectedDates, dateStr, instance ){ + const pickupDate_fp = document.getElementById("pickup-date")._flatpickr; + pickupDate_fp.set('disable', [function(date) { + return !slots_per_day.hasOwnProperty(date.getDay()); + }]); + pickupDate_fp.config.onClose.push(function( selectedDates, dateStr, instance ){ /* Here we add an onClose event to the existing flatpickr instance */ /* It fires after the user has selected a date from the calendar popup */ $('#pickup-times').html("
"); -- 2.30.2