From e5c20b1c535cde7fe5bb0f63a885e6f10c8a3929 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 Jan 2023 18:00:13 +0100 Subject: [PATCH] Bug 32559: Add support for formatted date when filtering on a column When dates are displayed formatted (following the dateformat syspref) in a DataTable table and that there is a filter for the column, we should filter correctly the data. Test plan: Assuming dateformat is set to metric Go to the main patron search, search for all patrons (don't provide a search term) In the "date of birth" column filter, enter "1958", notice that you see Henry Search using an iso formatted date 1958-05-30 Search using a metric formatted date 30/05/1958 Note that: - it's also working for "Expires on" on the same table. We may want to adjust other tables that are using the DT REST API wrapper and the column filters - You need to search for the full formatted date to make it work. "30/05" won't work. Signed-off-by: Lucas Gass Signed-off-by: Kyle M Hall --- .../intranet-tmpl/prog/en/includes/patron-search.inc | 4 ++-- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 3c1ce6fe2c..4f24c88338 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -149,14 +149,14 @@ [% SWITCH column %] [% CASE 'checkbox' %] [% CASE 'cardnumber' %]Card - [% CASE 'dateofbirth' %]Date of birth + [% CASE 'dateofbirth' %]Date of birth [% CASE 'name' %]Name [% CASE 'name-address' %]Name [% CASE 'address' %]Address [% CASE 'address-library' %]Address [% CASE 'branch' %]Library [% CASE 'category' %]Category - [% CASE 'dateexpiry' %]Expires on + [% CASE 'dateexpiry' %]Expires on [% CASE 'borrowernotes' %]Notes [% CASE 'phone' %]Phone [% CASE 'checkouts' %]Checkouts diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 8d79a44253..f309e794bb 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -663,8 +663,12 @@ function _dt_default_ajax (params){ if(query_parameters.length) { query_parameters = JSON.stringify(query_parameters.length === 1?query_parameters[0]:{"-and": query_parameters}); - dataSet.q = query_parameters; - delete options.query_parameters; + if(options.header_filter) { + options.query_parameters = query_parameters; + } else { + dataSet.q = query_parameters; + delete options.query_parameters; + } } else { delete options.query_parameters; } -- 2.41.0