From 1d9c0bd8bc93a6a782333da0e4e2fd9499c9fc99 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 a22d5dd4d5..0c6c4f6f2b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -584,13 +584,17 @@ 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"; } else { // escape SQL LIKE special characters % and _ value = value.replace(/(\%|\_|\\)/g, "\\$1"); } + 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