Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #430 Parameter overrides are shown with no clear distinction & Fix #347 [3D Viewer] Improvements on spacing and parameter editor #714

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PropertiesComponentTestFixture.cs" company="Starion Group S.A.">
// Copyright (c) 2023-2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar
//
// This file is part of CDP4-COMET WEB Community Edition
// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// <copyright file="PropertiesComponentTestFixture.cs" company="Starion Group S.A.">
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
//
// This file is part of COMET WEB Community Edition
// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Tests.Components.Viewer.PropertiesPanel
{
Expand All @@ -33,6 +33,7 @@ namespace COMETwebapp.Tests.Components.Viewer.PropertiesPanel
using CDP4Dal;

using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.Test.Helpers;

using COMETwebapp.Components.Viewer.PropertiesPanel;
using COMETwebapp.Model;
Expand Down Expand Up @@ -63,6 +64,7 @@ public class PropertiesComponentTestFixture
public void SetUp()
{
this.context = new TestContext();
this.context.ConfigureDevExpressBlazor();

var babylonService = new Mock<IBabylonInterop>();
this.context.Services.AddSingleton(babylonService);
Expand All @@ -81,13 +83,10 @@ public void SetUp()
this.viewModel = new PropertiesComponentViewModel(babylonService.Object, sessionService.Object, selectionMediator.Object, this.messageBus)
{
IsVisible = true,
ParameterValueSetRelations = new Dictionary<ParameterBase, IValueSet>()
ParameterValueSetRelations = []
};

this.renderedComponent = this.context.RenderComponent<PropertiesComponent>(parameters =>
{
parameters.Add(p => p.ViewModel, this.viewModel);
});
this.renderedComponent = this.context.RenderComponent<PropertiesComponent>(parameters => { parameters.Add(p => p.ViewModel, this.viewModel); });

this.properties = this.renderedComponent.Instance;
}
Expand All @@ -96,6 +95,8 @@ public void SetUp()
public void Teardown()
{
this.messageBus.ClearSubscriptions();
this.context.CleanContext();
this.context.Dispose();
}

[Test]
Expand All @@ -108,22 +109,12 @@ public void VerifyComponent()
});
}

[Test]
public void VerifyThatComponentCanBeHidden()
{
this.properties.ViewModel.IsVisible = true;
var component = this.renderedComponent.Find("#properties-header");
Assert.That(component, Is.Not.Null);
this.properties.ViewModel.IsVisible = false;
Assert.Throws<ElementNotFoundException>(() => this.renderedComponent.Find("#properties-header"));
}

[Test]
public void VerifyElementValueChanges()
{
var compoundData = new OrderedItemList<ParameterTypeComponent>(null)
{
new ParameterTypeComponent
new()
{
Iid = Guid.NewGuid(),
ShortName = "firstValue",
Expand All @@ -147,13 +138,13 @@ public void VerifyElementValueChanges()

parametertype.Component.AddRange(compoundData);

var parameter = new Parameter() { Iid = Guid.NewGuid(), ParameterType = parametertype };
var parameter = new Parameter { Iid = Guid.NewGuid(), ParameterType = parametertype };

this.viewModel.SelectedParameter = parameter;

var compoundValues = new List<string> { "1" };

var parameterValueSet = new ParameterValueSet()
var parameterValueSet = new ParameterValueSet
{
Iid = Guid.NewGuid(),
ValueSwitch = ParameterSwitchKind.MANUAL,
Expand All @@ -168,15 +159,25 @@ public void VerifyElementValueChanges()
});

var compoundValues1 = new List<string> { "false" };
var parameterValueSet1 = new ParameterValueSet()

var parameterValueSet1 = new ParameterValueSet
{
Iid = Guid.NewGuid(),
ValueSwitch = ParameterSwitchKind.MANUAL,
Manual = new ValueArray<string>(compoundValues1),
Manual = new ValueArray<string>(compoundValues1)
};

Assert.That(() => this.viewModel.ParameterValueSetChanged((parameterValueSet1,0)), Throws.Nothing);

Assert.That(() => this.viewModel.ParameterValueSetChanged((parameterValueSet1, 0)), Throws.Nothing);
}

[Test]
public void VerifyThatComponentCanBeHidden()
{
this.properties.ViewModel.IsVisible = true;
var component = this.renderedComponent.Find("#properties-header");
Assert.That(component, Is.Not.Null);
this.properties.ViewModel.IsVisible = false;
Assert.Throws<ElementNotFoundException>(() => this.renderedComponent.Find("#properties-header"));
}
}
}
11 changes: 10 additions & 1 deletion COMETwebapp/Components/ParameterEditor/ParameterTable.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@
CustomizeElement="this.OnCustomizeElement">
<Columns>
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ElementBaseName)" GroupIndex="0" GroupInterval="GridColumnGroupInterval.Value" Caption="@("Element Name")" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ParameterName)" Caption="@("Parameter")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.ParameterName)" Caption="@("Parameter")" AllowGroup="false" AllowSort="true">
<CellDisplayTemplate>
@context.DisplayText

@if (context.DataItem is ParameterBaseRowViewModel { Parameter: ParameterOverride })
{
<span class="fw-bold"> [Override]</span>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.Option)" Caption="@("Option")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.State)" Caption="@("State")" AllowGroup="false" AllowSort="true" />
<DxGridDataColumn FieldName="@nameof(ParameterBaseRowViewModel.PublishedValue)" Caption="@("Published Value")" AllowGroup="false" AllowSort="false" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!------------------------------------------------------------------------------
Copyright (c) 2023-2024 Starion Group S.A.

Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar
Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua

This file is part of CDP4-COMET WEB Community Edition
The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
Expand All @@ -19,29 +19,27 @@ Copyright (c) 2023-2024 Starion Group S.A.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
------------------------------------------------------------------------------->

@using CDP4Dal
@inherits DisposableComponent

<div id="propertiesPanel">

@if (this.ViewModel.IsVisible)
@if (this.ViewModel.IsVisible)
{
var selectedSceneObject = this.ViewModel.SelectionMediator.SelectedSceneObject;
var title = selectedSceneObject is not null ? selectedSceneObject.ElementBase.Name + " - Properties:" : "Properties";
var buttonClass = this.ViewModel.ParameterHaveChanges ? "submit-button button-blue" : "submit-button";

<div id="properties-header">
<h4 id="properties-title">@title</h4>
<button @onclick="()=>this.ViewModel.OnSubmit()" class="@buttonClass" disabled="@(!this.ViewModel.ParameterHaveChanges)">Submit</button>
<h4 id="properties-title">@(this.Title)</h4>
<DxButton Click="@(() => this.ViewModel.OnSubmit())"
Text="Submit"
Enabled="@(this.ViewModel.ParameterHaveChanges)"/>
</div>

<div id="parameters-section">
@{
var parameters = this.ViewModel.ParametersInUse is not null ? this.ViewModel.ParametersInUse : new List<CDP4Common.EngineeringModelData.ParameterBase>();
var parameters = this.ViewModel.ParametersInUse ?? [];

@foreach (var parameter in parameters)
{
var classNames = parameter == this.ViewModel.SelectedParameter ? "parameter-item parameter-item-selected" : "parameter-item";
<p class="@classNames" @onclick="()=> this.ViewModel.SelectedParameter = parameter">@parameter.ParameterType?.Name</p>
<p class="@classNames" @onclick="() => this.ViewModel.SelectedParameter = parameter">@parameter.ParameterType?.Name</p>
}
}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,54 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PropertiesComponent.razor.cs" company="Starion Group S.A.">
// Copyright (c) 2023-2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar
//
// This file is part of CDP4-COMET WEB Community Edition
// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// <copyright file="PropertiesComponent.razor.cs" company="Starion Group S.A.">
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua
//
// This file is part of COMET WEB Community Edition
// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C.
//
// The COMET WEB Community Edition is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// The COMET WEB Community Edition is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.Components.Viewer.PropertiesPanel
{
using COMET.Web.Common.Components;
using COMET.Web.Common.Extensions;

using COMETwebapp.ViewModels.Components.Viewer.PropertiesPanel;

using Microsoft.AspNetCore.Components;
using ReactiveUI;

using ReactiveUI;

/// <summary>
/// The properties component used for displaying data about the selected primitive
/// </summary>
public partial class PropertiesComponent
{
public partial class PropertiesComponent : DisposableComponent
{
/// <summary>
/// Gets or sets the <see cref="IPropertiesComponentViewModel"/>
/// Gets or sets the <see cref="IPropertiesComponentViewModel" />
/// </summary>
[Parameter]
public IPropertiesComponentViewModel ViewModel { get; set; }

public IPropertiesComponentViewModel ViewModel { get; set; }

/// <summary>
/// Gets the properties component title
/// </summary>
private string Title => this.ViewModel.SelectionMediator.SelectedSceneObject is not null ? this.ViewModel.SelectionMediator.SelectedSceneObject.ElementBase.Name + " - Properties:" : "Properties";

/// <summary>
/// Method invoked when the component is ready to start, having received its
/// initial parameters from its parent in the render tree.
Expand All @@ -49,9 +57,11 @@ protected override void OnInitialized()
{
base.OnInitialized();

this.WhenAnyValue(x => x.ViewModel.IsVisible,
x => x.ViewModel.SelectedParameter,
x => x.ViewModel.ParameterHaveChanges).Subscribe(_ => this.InvokeAsync(this.StateHasChanged));
this.Disposables.Add(this.WhenAnyValue(
x => x.ViewModel.IsVisible,
x => x.ViewModel.SelectedParameter,
x => x.ViewModel.ParameterHaveChanges)
.SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged)));
}
}
}
1 change: 1 addition & 0 deletions COMETwebapp/Components/Viewer/ViewerBody.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
grid-template-rows: 1fr;
grid-column-gap: 0px;
grid-row-gap: 0px;
gap: 10px;
}

#leftColumn {
Expand Down
Loading
Loading