From 04854ec6d84624f0e9f74e159636a36f74cfd70f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 21 Oct 2024 14:17:55 +0200 Subject: [PATCH] Bug 33484: External filter into state - support flatpickr Signed-off-by: Pedro Amorim Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 7a073e1318..cdb506d849 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -1040,13 +1040,21 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){ if (data.external_filters.hasOwnProperty(k)) { let node = $(external_filter_nodes[k]); let tag_name = node.prop("tagName"); + let value = data.external_filters[k]; if ( tag_name == "INPUT" && node.prop("type") == "checkbox" ) { - node.prop("checked", data.external_filters[k]); + node.prop("checked", value); + } else if ( + tag_name == "INPUT" && + node.hasClass("flatpickr") + ) { + const fp = + document.querySelector(external_filter_nodes[k])._flatpickr; + fp.setDate(value); } else if (tag_name == "INPUT" || tag_name == "SELECT") { - node.val(data.external_filters[k]); + node.val(value); } else { console.log( "Tag '%s' not supported yet for DT state".format( -- 2.39.5