From 72788474b511f84af813c9ccde47039f4edb3caa 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 Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 5b25b26f70c21c609793f10706c04c9dbce4a5ad) Signed-off-by: Fridolin Somers --- 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 95ada9bc07..f4b33c2d3e 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.39.5