From 087e576cdb8b7ad2a9cd955623662641e42f4310 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 18 Jul 2025 15:14:12 +0200 Subject: [PATCH] Bug 36136: Make sure 'to' dates are instantiated with the 'from' dates as minimum --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 681e8cc4013..a5962de0265 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -114,6 +114,17 @@ } } new Maskito( instance.altInput, maskitoOptions ); + + /* If there is a node with data-date_to with the id of this node it means we are instantiating a 'from' for a date range */ + const toInput = instance.input; + const fromInput = document.querySelector(`[data-date_to='${toInput.id}']`); + if (fromInput && fromInput._flatpickr) { + const fromDate = fromInput._flatpickr.selectedDates[0]; + if (fromDate) { + instance.set('minDate', fromDate); + } + } + }, onChange: function( selectedDates, dateText, instance) { if (selectedDates.length === 0) { -- 2.34.1