SearchKit - Fix regression for pseudoconstant selection
authorColeman Watts <coleman@civicrm.org>
Tue, 30 Nov 2021 17:02:47 +0000 (12:02 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 30 Nov 2021 17:02:47 +0000 (12:02 -0500)
Fixes dev/report#83

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

index de886f38eb3434fb67218a4b34880eb9260b5760..558e4817b6556116512f6481a583fb44f2b39737 100644 (file)
         }
       }
 
-      this.getField = function(expr) {
+      // Gets the first arg of type "field"
+      function getFirstArgFromExpr(expr) {
         if (!(expr in meta)) {
           meta[expr] = _.findWhere(searchMeta.parseExpr(expr).args, {type: 'field'});
         }
-        return meta[expr] && meta[expr].field;
+        return meta[expr] || {};
+      }
+
+      this.getField = function(expr) {
+        return getFirstArgFromExpr(expr).field;
       };
 
       this.getOptionKey = function(expr) {
-        var field = ctrl.getField(expr) || {};
-        return field.suffix ? field.suffix.slice(1) : 'id';
+        var arg = getFirstArgFromExpr(expr);
+        return arg.suffix ? arg.suffix.slice(1) : 'id';
       };
 
       this.addGroup = function(op) {