From f9bb820af05dbdf339ccdc0443abadfdc4fc5662 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 26 Oct 2022 23:17:21 -0400 Subject: [PATCH] SearchKit - Set better default when selecting math function Instead of a blank field selector with no way to clear it, it now picks the first available field for you so it's easier to clear and replace with a number if you so choose. --- .../crmSearchAdmin/crmSearchFunction.component.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js index 86e063834f..a9c7496cdd 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js @@ -45,12 +45,20 @@ }); this.addArg = function(exprType) { - var param = ctrl.getParam(ctrl.args.length); + var param = ctrl.getParam(ctrl.args.length), + val = ''; + if (exprType === 'SqlNumber') { + // Number: default to 0 + val = 0; + } else if (exprType === 'SqlField') { + // Field: Default to first available field, making it easier to delete the value + val = ctrl.getFields().results[0].children[0].id; + } ctrl.args.push({ type: ctrl.exprTypes[exprType].type, flag_before: _.filter(_.keys(param.flag_before))[0], name: param.name, - value: exprType === 'SqlNumber' ? 0 : '' + value: val }); }; -- 2.25.1