From fb7bd1c77a4c8da035cd2552197b23aa41dc3da2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 18 Feb 2013 11:35:58 +0530 Subject: [PATCH] replace undefined values with null in filters returned by get query before calling search or autocomplete --- public/js/legacy/webpage/search.js | 13 ++++++++----- public/js/legacy/widgets/form/fields.js | 9 +++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/public/js/legacy/webpage/search.js b/public/js/legacy/webpage/search.js index d782cd3331..e6bb086c68 100644 --- a/public/js/legacy/webpage/search.js +++ b/public/js/legacy/webpage/search.js @@ -155,11 +155,14 @@ function makeselector() { if (typeof(q)==="string") { args.query = q; - } else { - // replaced $.extend(args, q) - $.each(q, function(key, value) { - args[key] = value; - }); + } else if($.isPlainObject(q)) { + if(q.filters) { + $.each(q.filters, function(key, value) { + q.filters[key] = value===undefined ? null : value; + }); + } + + $.extend(args, q); } } diff --git a/public/js/legacy/widgets/form/fields.js b/public/js/legacy/widgets/form/fields.js index 2bdc997d2c..bb348cf4f2 100644 --- a/public/js/legacy/widgets/form/fields.js +++ b/public/js/legacy/widgets/form/fields.js @@ -639,10 +639,15 @@ LinkField.prototype.make_input = function() { var q = me.get_custom_query(); if (typeof(q)==="string") { args.query = q; - } else { + } else if($.isPlainObject(q)) { + if(q.filters) { + $.each(q.filters, function(key, value) { + q.filters[key] = value===undefined ? null : value; + }); + } $.extend(args, q); } - + wn.call({ method:'webnotes.widgets.search.search_link', args: args,