Skip to content

Commit

Permalink
Closed #54 Sorting relationships in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Feb 3, 2020
1 parent ac64e6e commit d634f94
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions LCG-UDG/LCG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ private void DisplayFilteredRelationships()
if (selectedEntity?.Relationships != null && selectedEntity.Relationships.Count > 0)
{
GetSettingsFromUI();
var filteredRelationships = GetFilteredRelationships(selectedEntity, txtRelSearch.Text);
var filteredRelationships = GetFilteredRelationships(selectedEntity, txtRelSearch.Text)
.OrderBy(r => r.LookupName)
.OrderBy(r => r.OtherEntity?.DisplayName)
.OrderBy(r => r.Type);
gridRelationships.DataSource = new SortableBindingList<RelationshipMetadataProxy>(filteredRelationships);
if (gridRelationships.Columns.Count > 0)
{
Expand Down Expand Up @@ -620,7 +623,7 @@ bool GetInternalFilter(AttributeMetadataProxy a)
&& GetManagedFilter(a)
&& GetSearchFilter(a)
&& GetLogicalFilter(a)
&&GetInternalFilter(a));
&& GetInternalFilter(a));
}

private IEnumerable<EntityMetadataProxy> GetFilteredEntities()
Expand Down Expand Up @@ -661,18 +664,18 @@ private IEnumerable<RelationshipMetadataProxy> GetFilteredRelationships(EntityMe
{
bool GetTypeFilter(RelationshipMetadataProxy r)
{ // Exclude relationships where selected entity is just child of the relationship
if (settings.RelationshipFilter.Type1N &&
if (settings.RelationshipFilter.Type1N &&
r.OneToManyRelationshipMetadata?.ReferencedEntity == entity?.LogicalName)
{
return true;
}
if (settings.RelationshipFilter.TypeN1 &&
r.OneToManyRelationshipMetadata?.ReferencingEntity == entity?.LogicalName &&
if (settings.RelationshipFilter.TypeN1 &&
r.OneToManyRelationshipMetadata?.ReferencingEntity == entity?.LogicalName &&
r.OneToManyRelationshipMetadata?.ReferencedEntity != entity?.LogicalName) // Exclude self-referencing relationships, they are included as 1:N
{
return true;
}
if (settings.RelationshipFilter.TypeNN &&
if (settings.RelationshipFilter.TypeNN &&
r.Metadata.RelationshipType == RelationshipType.ManyToManyRelationship)
{
return true;
Expand Down

0 comments on commit d634f94

Please sign in to comment.