SearchKit - Fix CONCAT_WS & any function that doesn't take a field as 1st arg
authorColeman Watts <coleman@civicrm.org>
Mon, 20 Dec 2021 05:31:36 +0000 (00:31 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 20 Dec 2021 05:31:36 +0000 (00:31 -0500)
Fixes dev/report#88
See https://lab.civicrm.org/dev/report/-/issues/88

ext/search_kit/ang/crmSearchAdmin/crmSearchFunction.component.js

index 3fda35afe004bb38c7ad97ce04bf855633d03943..3673bf809b1e02fb9e093cd0ed41db9fb1b11b95 100644 (file)
         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 : ''