From 0528aa82e988fce4b5f4352673b6e336739ee321 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 15 Sep 2021 10:22:02 -0400 Subject: [PATCH] SearchKit - Fix links to non-aggregage join fields --- .../ang/crmSearchAdmin/crmSearchAdmin.component.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js index 6208ce61299a..ebc00da41f5d 100644 --- a/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/crmSearchAdmin.component.js @@ -620,13 +620,16 @@ var join = searchMeta.getJoin(joinClause[0]), joinEntity = searchMeta.getEntity(join.entity), primaryKey = joinEntity.primary_key[0], + // Links for aggregate columns get aggregated using GROUP_CONCAT isAggregate = ctrl.canAggregate(join.alias + '.' + primaryKey), - joinPrefix = (isAggregate ? 'GROUP_CONCAT_' : '') + join.alias + '.', + joinPrefix = (isAggregate ? ctrl.DEFAULT_AGGREGATE_FN + '_' : '') + join.alias + '.', bridgeEntity = _.isString(joinClause[2]) ? searchMeta.getEntity(joinClause[2]) : null; _.each(joinEntity.paths, function(path) { var link = _.cloneDeep(path); - link.isAggregate = isAggregate; - link.path = link.path.replace(/\[/g, '[' + joinPrefix).replace(/[.:]/g, '_'); + link.path = link.path.replace(/\[/g, '[' + joinPrefix); + if (isAggregate) { + link.path = link.path.replace(/[.:]/g, '_'); + } link.join = join.alias; addTitle(link, join.label); links.push(link);