From 5d47731b91d2585b312b2e3235c324fb7ab73540 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 14 Jul 2022 08:24:12 +0100 Subject: [PATCH] Bug 31028: Add 'special:undefined' to handle passing 'null' We can't pass 'null' to the column.search as it gets stringified. This patch adds a special string 'special:undefined' to denote that we want to search on undef for the field in question. --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index f4247ae343..f5c867fd8a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -587,10 +587,14 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { var part = {}; var attr = attributes[i]; let criteria = options.criteria; - if ( value.match(/^\^(.*)\$$/) ) { + if ( value !== null && value.match(/^\^(.*)\$$/) ) { value = value.replace(/^\^/, '').replace(/\$$/, ''); criteria = "exact"; } + if ( value === 'special:undefined' ) { + value = null; + criteria = "exact"; + } part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact' ? value : {like: (['contains', 'ends_with'].indexOf(criteria) !== -1?'%':'') + value + (['contains', 'starts_with'].indexOf(criteria) !== -1?'%':'')}; -- 2.20.1