From fa0231bf17137eb8a0618ad29a681d263cb6d21e 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 --- 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 d189c1deaed..f0275520539 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