From 2e7eb3dec69b6311eac57e72cac4e1fabec1a1d4 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/ --- .../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 00616359eee..8cf12f69b62 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 14b3ffc7a95..c24d1255ba2 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.25.1