From e332c7ef64ff9d73981ed68f248c5d836e907d4a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 16 Jul 2021 11:06:41 -0400 Subject: [PATCH] APIv4 Explorer - Fix display of bridge entity fields for symmetric bridge Symmetric bridge entities such as RelationshipCache which joins Contact to Contact need to have the second entity id availble to join on. --- ang/api4Explorer/Explorer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ang/api4Explorer/Explorer.js b/ang/api4Explorer/Explorer.js index a0cdc38ac8..2bdaa72b11 100644 --- a/ang/api4Explorer/Explorer.js +++ b/ang/api4Explorer/Explorer.js @@ -142,11 +142,14 @@ if (join.bridge) { var bridgeFields = _.cloneDeep(entityFields(join.bridge)), bridgeEntity = getEntity(join.bridge), - joinFieldNames = _.pluck(joinFields, 'name'); + joinFieldNames = _.pluck(joinFields, 'name'), + // Check if this is a symmetric bridge e.g. RelationshipCache joins Contact to Contact + bridgePair = _.keys(bridgeEntity.bridge), + symmetric = getField(bridgePair[0], join.bridge).entity === getField(bridgePair[1], join.bridge).entity; _.each(bridgeFields, function(field) { if ( // Only include bridge fields that link back to the original entity - (!bridgeEntity.bridge[field.name] || field.fk_entity !== join.entity) && + (!bridgeEntity.bridge[field.name] || field.fk_entity !== join.entity || symmetric) && // Exclude fields with the same name as those in the original entity !_.includes(joinFieldNames, field.name) ) { -- 2.25.1