From 173fedce312702e36c2464699701ef17f3b3b2be Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 4 Mar 2024 18:05:40 +0000 Subject: [PATCH] Bug 33703: Don't use Maskito when picking a range Signed-off-by: Martin Renvoize Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer --- .../prog/en/includes/calendar.inc | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 2edabb3d65..16ec8bcd44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -85,30 +85,36 @@ onChange: function( selectedDates, dateText, instance) { var thisInput = instance.input; let accepts_time = $(thisInput).data('flatpickr-enable-time'); - if ( accepts_time ) { - let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat); - if ( !parsedDate.getHours() ) { - instance.setDate(selectedDates[0].setHours(23, 59, 0, 0)); + let accepts_period = $(thisInput).data('flatpickr-period'); + if ( !accepts_period ) { + if ( accepts_time ) { + let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat); + if ( !parsedDate.getHours() ) { + instance.setDate(selectedDates[0].setHours(23, 59, 0, 0)); + } } } }, onOpen: function( selectedDates, dateText, instance ) { var thisInput = instance.input; let accepts_time = $(thisInput).data('flatpickr-enable-time'); + let accepts_period = $(thisInput).data('flatpickr-period'); let options = {}; - if ( accepts_time ) { - options = maskitoDateTimeOptionsGenerator({ - dateMode: altinput_dateformat, - timeMode: 'HH:MM', - dateSeparator: delimiter, - }); - } else { - options = maskitoDateOptionsGenerator({ - mode: altinput_dateformat, - separator: delimiter, - }); + if ( !accepts_period ) { + if ( accepts_time ) { + options = maskitoDateTimeOptionsGenerator({ + dateMode: altinput_dateformat, + timeMode: 'HH:MM', + dateSeparator: delimiter, + }); + } else { + options = maskitoDateOptionsGenerator({ + mode: altinput_dateformat, + separator: delimiter, + }); + } + new Maskito( instance.altInput, options ); } - new Maskito( instance.altInput, options ); }, onClose: function( selectedDates, dateText, instance) { validate_date( dateText, instance ); -- 2.39.5