From 68a72bc9f17dc44f8714051170a4b287be1746a8 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 20 Dec 2021 00:31:36 -0500 Subject: [PATCH] SearchKit - Fix CONCAT_WS & any function that doesn't take a field as 1st arg Fixes dev/report#88 See https://lab.civicrm.org/dev/report/-/issues/88 --- .../ang/crmSearchAdmin/crmSearchFunction.component.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js index 3fda35afe0..3673bf809b 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js @@ -118,11 +118,11 @@ delete ctrl.fieldArg.flag_before; ctrl.args = [ctrl.fieldArg]; if (ctrl.fn) { - var exprType, pos = 0, - uiDefaults = ctrl.fn.params[0].ui_defaults || []; + var exprType, + pos = 0; // Add non-field args to the beginning if needed - while (uiDefaults[pos] && uiDefaults[pos].type && uiDefaults[pos].type !== 'SqlField') { - exprType = uiDefaults[pos].type; + while (!_.includes(ctrl.fn.params[pos].must_be, 'SqlField')) { + exprType = ctrl.fn.params[pos].must_be[0]; ctrl.args.splice(pos, 0, { type: ctrl.exprTypes[exprType].type, value: exprType === 'SqlNumber' ? 0 : '' -- 2.25.1