From 860f7244714109f58ce8bd96476de96e3f2d7919 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 30 Nov 2021 12:02:47 -0500 Subject: [PATCH] SearchKit - Fix regression for pseudoconstant selection Fixes dev/report#83 --- .../ang/crmSearchAdmin/crmSearchClause.component.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchClause.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchClause.component.js index de886f38eb..558e4817b6 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchClause.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchClause.component.js @@ -61,16 +61,21 @@ } } - 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) { -- 2.25.1