-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cyclic ratio, interval, ordinal and rate scales creation/edit impleme…
…nted + mappings and scale value definitions TODO - Support logarithmic scale data - Show error message in case of invalid data - Validation - Unit tests
- Loading branch information
Showing
15 changed files
with
920 additions
and
141 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
COMETwebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!------------------------------------------------------------------------------ | ||
Copyright (c) 2023-2024 RHEA System S.A. | ||
Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Antoine Théate, João Rua | ||
This file is part of CDP4-COMET WEB Community Edition | ||
The CDP4-COMET WEB Community Edition is the RHEA 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 | ||
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/. | ||
-------------------------------------------------------------------------------> | ||
|
||
<DxGrid @ref="this.Grid" | ||
Data="this.GetRows()" | ||
EditMode="GridEditMode.PopupEditForm" | ||
PopupEditFormHeaderText="Mapping To Reference Scale" | ||
EditModelSaving="@(() => this.OnEditMappingToReferenceScaleSaving())" | ||
CustomizeEditModel="this.CustomizeEditMappingToReferenceScale"> | ||
<Columns> | ||
<DxGridDataColumn FieldName="@nameof(MappingToReferenceScaleRowViewModel.Reference)" MinWidth="80" /> | ||
<DxGridDataColumn FieldName="@nameof(MappingToReferenceScaleRowViewModel.ReferenceValue)" MinWidth="80" /> | ||
<DxGridDataColumn FieldName="@nameof(MappingToReferenceScaleRowViewModel.Dependent)" MinWidth="80" /> | ||
<DxGridDataColumn FieldName="@nameof(MappingToReferenceScaleRowViewModel.DependentValue)" MinWidth="80" /> | ||
<DxGridCommandColumn Width="100px" EditButtonVisible="false"> | ||
<HeaderTemplate> | ||
<DxButton Id="addMappingToReferenceScaleButton" Text="Add" IconCssClass="oi oi-plus" Click="() => this.Grid.StartEditNewRowAsync()" /> | ||
</HeaderTemplate> | ||
<CellDisplayTemplate> | ||
@{ | ||
var row = (MappingToReferenceScaleRowViewModel)context.DataItem; | ||
|
||
<DxButton Id="editMappingToReferenceScaleButton" | ||
IconCssClass="oi oi-pencil" | ||
Click="@(() => this.Grid.StartEditRowAsync(context.VisibleIndex))"/> | ||
|
||
<DxButton Id="removeMappingToReferenceScaleButton" | ||
IconCssClass="oi oi-trash" | ||
Click="() => this.RemoveMappingToReferenceScale(row)"/> | ||
} | ||
</CellDisplayTemplate> | ||
</DxGridCommandColumn> | ||
</Columns> | ||
|
||
<EditFormTemplate Context="EditFormContext"> | ||
<FluentValidationValidator /> | ||
<DxFormLayout CssClass="w-100"> | ||
<DxFormLayoutItem Caption="Reference Scale Value:" ColSpanMd="10"> | ||
<DxComboBox Data="@this.ReferenceScaleValueDefinitions" | ||
TextFieldName="@nameof(ScaleValueDefinition.ShortName)" | ||
@bind-Value="@this.MappingToReferenceScale.ReferenceScaleValue" | ||
CssClass="cw-480"/> | ||
</DxFormLayoutItem> | ||
|
||
<DxFormLayoutItem Caption="Dependent Scale Value:" ColSpanMd="10"> | ||
<DxComboBox Data="@this.DependentScaleValueDefinitions" | ||
TextFieldName="@nameof(ScaleValueDefinition.ShortName)" | ||
@bind-Value="@this.MappingToReferenceScale.DependentScaleValue" | ||
CssClass="cw-480" /> | ||
</DxFormLayoutItem> | ||
</DxFormLayout> | ||
<div class="pt-3"></div> | ||
<ValidationSummary /> | ||
</EditFormTemplate> | ||
</DxGrid> |
138 changes: 138 additions & 0 deletions
138
...Twebapp/Components/ReferenceData/MeasurementScales/MappingToReferenceScalesTable.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="MappingToReferenceScalesTable.razor.cs" company="RHEA System S.A."> | ||
// Copyright (c) 2023-2024 RHEA System S.A. | ||
// | ||
// 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 RHEA 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 | ||
// 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> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace COMETwebapp.Components.ReferenceData.MeasurementScales | ||
{ | ||
using CDP4Common.SiteDirectoryData; | ||
|
||
using COMETwebapp.ViewModels.Components.ReferenceData.Rows; | ||
|
||
using DevExpress.Blazor; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
|
||
/// <summary> | ||
/// Support class for the <see cref="MappingToReferenceScalesTable"/> | ||
/// </summary> | ||
public partial class MappingToReferenceScalesTable | ||
{ | ||
/// <summary> | ||
/// A collection of mapping to reference scale to display for selection | ||
/// </summary> | ||
[Parameter] | ||
public IEnumerable<MappingToReferenceScale> MappingToReferenceScales { get; set; } | ||
|
||
/// <summary> | ||
/// The method that is executed when the mapping to reference scales change | ||
/// </summary> | ||
[Parameter] | ||
public EventCallback<IEnumerable<MappingToReferenceScale>> MappingToReferenceScalesChanged { get; set; } | ||
|
||
/// <summary> | ||
/// A collection of dependent scale value definitions to display for selection | ||
/// </summary> | ||
[Parameter] | ||
public IEnumerable<ScaleValueDefinition> DependentScaleValueDefinitions { get; set; } | ||
|
||
/// <summary> | ||
/// A collection of reference scale value definitions to display for selection | ||
/// </summary> | ||
[Parameter] | ||
public IEnumerable<ScaleValueDefinition> ReferenceScaleValueDefinitions { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the condition to check if a mapping to reference scale should be created | ||
/// </summary> | ||
public bool ShouldCreate { get; private set; } | ||
|
||
/// <summary> | ||
/// The mapping to reference scale that will be handled for both edit and add forms | ||
/// </summary> | ||
private MappingToReferenceScale MappingToReferenceScale { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// Gets or sets the grid control that is being customized. | ||
/// </summary> | ||
private IGrid Grid { get; set; } | ||
|
||
/// <summary> | ||
/// Method that is invoked when the edit/add mapping to reference scale form is being saved | ||
/// </summary> | ||
private void OnEditMappingToReferenceScaleSaving() | ||
{ | ||
var mappingToReferenceScalesList = this.MappingToReferenceScales.ToList(); | ||
|
||
if (this.ShouldCreate) | ||
{ | ||
mappingToReferenceScalesList.Add(this.MappingToReferenceScale); | ||
this.MappingToReferenceScales = mappingToReferenceScalesList; | ||
} | ||
else | ||
{ | ||
var indexToUpdate = mappingToReferenceScalesList.FindIndex(x => x.Iid == this.MappingToReferenceScale.Iid); | ||
mappingToReferenceScalesList[indexToUpdate] = this.MappingToReferenceScale; | ||
} | ||
|
||
this.MappingToReferenceScales = mappingToReferenceScalesList; | ||
this.MappingToReferenceScalesChanged.InvokeAsync(this.MappingToReferenceScales); | ||
} | ||
|
||
/// <summary> | ||
/// Method that is invoked when a mapping to reference scale row is being removed | ||
/// </summary> | ||
private void RemoveMappingToReferenceScale(MappingToReferenceScaleRowViewModel row) | ||
{ | ||
var mappingToReferenceScalesList = this.MappingToReferenceScales.ToList(); | ||
mappingToReferenceScalesList.Remove(row.MappingToReferenceScale); | ||
|
||
this.MappingToReferenceScales = mappingToReferenceScalesList; | ||
this.MappingToReferenceScalesChanged.InvokeAsync(this.MappingToReferenceScales); | ||
} | ||
|
||
/// <summary> | ||
/// Method invoked when creating a new Mapping To Reference Scale | ||
/// </summary> | ||
/// <param name="e">A <see cref="GridCustomizeEditModelEventArgs" /></param> | ||
private void CustomizeEditMappingToReferenceScale(GridCustomizeEditModelEventArgs e) | ||
{ | ||
var dataItem = (MappingToReferenceScaleRowViewModel)e.DataItem; | ||
this.ShouldCreate = e.IsNew; | ||
|
||
this.MappingToReferenceScale = dataItem == null | ||
? new MappingToReferenceScale() { Iid = Guid.NewGuid() } | ||
: dataItem.MappingToReferenceScale.Clone(true); | ||
|
||
e.EditModel = this.MappingToReferenceScale; | ||
} | ||
|
||
/// <summary> | ||
/// Method used to retrieve the available rows, given the <see cref="MappingToReferenceScales"/> | ||
/// </summary> | ||
/// <returns>A collection of <see cref="MappingToReferenceScaleRowViewModel"/>s to display</returns> | ||
private List<MappingToReferenceScaleRowViewModel> GetRows() | ||
{ | ||
return this.MappingToReferenceScales.Select(x => new MappingToReferenceScaleRowViewModel(x)).ToList(); | ||
} | ||
} | ||
} |
Oops, something went wrong.