From 4c67e639772f13d715da4f5a825f7d46aceb2c96 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 9 Oct 2023 16:37:22 +0100 Subject: [PATCH] Bug 35014: Only set time for enable-time flatpickr This patch adds a check to the onChange function such that we only attempt to set the default time on change for time enabled flatpickrs when the date is entered manually. Signed-off-by: Lucas Gass Signed-off-by: Katrin Fischer --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index d189c1deae..f027552053 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -71,9 +71,13 @@ }); }, onChange: function( selectedDates, dateText, instance) { - let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat); - if ( !parsedDate.getHours() ) { - instance.setDate(selectedDates[0].setHours(23, 59, 0, 0)); + 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)); + } } }, onClose: function( selectedDates, dateText, instance) { -- 2.30.2