Skip to content

Commit

Permalink
Show complete group hierarchy path instead of only main group
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander van Delft committed Dec 5, 2024
1 parent a4905a8 commit a428c72
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ParameterTableViewModelTestFixture
private Option option;
private CDPMessageBus messageBus;
private ParameterGroup parameterGroup;
private ParameterGroup parameterGroup2;

[SetUp]
public void Setup()
Expand Down Expand Up @@ -93,6 +94,13 @@ public void Setup()
Name = "ParameterGroup 1"
};

this.parameterGroup2 = new ParameterGroup()
{
Iid = Guid.NewGuid(),
Name = "ParameterGroup 2",
ContainingGroup = this.parameterGroup
};

var parameter1 = new Parameter()
{
Iid = Guid.NewGuid(),
Expand Down Expand Up @@ -139,7 +147,7 @@ public void Setup()
ParameterType = parameterType,
Scale = scale,
Owner = this.domain,
Group = this.parameterGroup,
Group = this.parameterGroup2,
ValueSet =
{
new ParameterValueSet()
Expand Down Expand Up @@ -177,7 +185,7 @@ public void Setup()
Iid = Guid.NewGuid(),
Name = "Container",
Parameter = { parameter3 },
ParameterGroup = { this.parameterGroup }
ParameterGroup = { this.parameterGroup, this.parameterGroup2 }
};

var elementDefinition = new ElementDefinition()
Expand Down Expand Up @@ -239,7 +247,7 @@ public void VerifyParameterRowProperties()
Assert.That(parameterRow.ParameterName, Is.EqualTo("mass"));
Assert.That(parameterRow.Option, Is.Empty);
Assert.That(parameterRow.State, Is.Empty);
Assert.That(parameterRow.ParameterGroupName, Is.EqualTo(this.parameterGroup.Name));
Assert.That(parameterRow.ParameterGroupPath, Is.EqualTo($"{this.parameterGroup.Name} => {this.parameterGroup2.Name}"));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
</DxGridDataColumn>
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ModelCode)" Caption="@("Model Code")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.OwnerName)" Caption="@("Owner")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ParameterGroupName)" Caption="@("Parameter Group")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ParameterGroupPath)" Caption="@("Parameter Group Path")" AllowGroup="false" AllowSort="true" />
</Columns>
</DxGrid>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,28 @@ private void InitializesProperties(bool isReadOnly)
/// </summary>
private void CalculateParameterGroupData()
{
var parameterGroupName = string.Empty;
var parameterGroupPath = string.Empty;

if (this.Parameter.Group != null)
{
parameterGroupName = this.Parameter.Group.Name;
var group = this.Parameter.Group;
parameterGroupPath = this.Parameter.Group.Name;

while (true)
{
if (group.ContainingGroup != null)
{
parameterGroupPath = $"{group.ContainingGroup.Name} => {parameterGroupPath}";
group = group.ContainingGroup;
}
else
{
break;

Check warning on line 139 in COMETwebapp/ViewModels/Components/ParameterEditor/ParameterBaseRowViewModel.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor the code in order to remove this break statement. (https://rules.sonarsource.com/csharp/RSPEC-1227)
}
}
}

this.ParameterGroupName = parameterGroupName;
this.ParameterGroupPath = parameterGroupPath;
}

/// <summary>
Expand Down Expand Up @@ -187,7 +201,7 @@ public bool IsPublishable
/// <summary>
/// Gets the <see cref="ParameterGroup" /> name
/// </summary>
public string ParameterGroupName { get; private set; }
public string ParameterGroupPath { get; private set; }

/// <summary>
/// Gets the switch for the published value
Expand Down

0 comments on commit a428c72

Please sign in to comment.