From: Coleman Watts Date: Mon, 20 Dec 2021 05:31:36 +0000 (-0500) Subject: SearchKit - Fix CONCAT_WS & any function that doesn't take a field as 1st arg X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=68a72bc9f17dc44f8714051170a4b287be1746a8;p=civicrm-core.git 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 --- 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 : ''