From c164194f41ead0d3a9058d8a6951d0b98d1d97ef 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 Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- .../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 26b892d198..c3b729f83f 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 @@ -350,8 +350,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.39.2