From 67c00223ff2ff44adbb79540800baf3441d77067 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Jan 2024 11:56:16 +0100 Subject: [PATCH] Bug 35341: Do not reinstantiate flatpickr We do not need to reinstantiate flatpickr, we need to retrieve the existing instance. --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 1 + .../intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index f0275520539..076820873ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -200,6 +200,7 @@ fp.set("maxDate", now.setMinutes(now.getMinutes() + 1)); }, 30000); } + return fp; } $(document).ready(function(){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 0ad2b55cff5..e3edc701bc4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -1505,16 +1505,16 @@ } else if ( i == 9 ) { // specific processing for Hard due date $(current_column).find("select").val(itm_code); - if (itm_text) { + if (is_valid_date(itm_text)) { input_values = itm_text.split(' '); - var fp = $('#hardduedate').flatpickr(); + var fp = document.querySelector("#hardduedate")._flatpickr; var hardduedate = fp.parseDate( input_values[1], flatpickr_dateformat_string ); if( hardduedate) fp.setDate( hardduedate, 1 ); } } else if ( i == 26 ) { // specific processing for No automatic renewal after (hard limit) - if (itm_text) { - var fp = $('#no_auto_renewal_after_hard_limit').flatpickr(); + if (is_valid_date(itm_text)) { + var fp = document.querySelector("#no_auto_renewal_after_hard_limit")._flatpickr; var renewdate = fp.parseDate( itm_text, flatpickr_dateformat_string ); if( renewdate) fp.setDate( renewdate, 1 ); } -- 2.34.1