From caf87e47166af81ac49dfdd15c5f6b16c400086f 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 21dfe52636..857d36ad46 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