Skip to content

Commit

Permalink
Batch parameter edit component created
Browse files Browse the repository at this point in the history
TODO
- Finish implementation
- Put component inside a popup
- Unit tests
  • Loading branch information
joao4all committed Apr 26, 2024
1 parent 06405f2 commit b082fdb
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@if (this.ViewModel.CurrentIteration != null)
{
<h6>Filter on Parameter Type:</h6>
<h6>@(this.DisplayText)</h6>
<DxComboBox Data="@this.ViewModel.AvailableParameterTypes"
AllowUserInput="true"
@bind-Value="@this.ViewModel.SelectedParameterType"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ParameterTypeSelector.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.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace COMET.Web.Common.Components.Selectors
{
using CDP4Common.SiteDirectoryData;

using Microsoft.AspNetCore.Components;

/// <summary>
/// Component used to select a <see cref="ParameterType" />
/// </summary>
public partial class ParameterTypeSelector
{
/// <summary>
/// Text to be displayed when the selector is shown
/// </summary>
[Parameter]
public string DisplayText { get; set; } = "Filter on Parameter Type:";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ namespace COMET.Web.Common.ViewModels.Components.Selectors
{
using CDP4Common.SiteDirectoryData;

using COMET.Web.Common.Extensions;

using ReactiveUI;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!------------------------------------------------------------------------------
// 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/.
------------------------------------------------------------------------------->
@inherits DisposableComponent

<ParameterTypeSelector ViewModel="this.ViewModel.ParameterTypeSelector"
DisplayText="Select a parameter type:"/>

<ParameterTypeEditorSelector BindValueMode="BindValueMode.OnDelayedInput"
IsOnEditMode="false"
ViewModel="@(this.ViewModel.ParameterTypeEditorSelectorViewModel)"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BatchParameterEditor.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.ParameterEditor.BatchParameterEditor
{
using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor;

using DevExpress.Blazor;

using Microsoft.AspNetCore.Components;

using ReactiveUI;

/// <summary>
/// Class for the component <see cref="BatchParameterEditor" />
/// </summary>
public partial class BatchParameterEditor
{
/// <summary>
/// Gets or sets the <see cref="IBatchParameterEditorViewModel" />
/// </summary>
[Parameter]
public IBatchParameterEditorViewModel ViewModel { get; set; }

/// <summary>
/// Gets or sets the grid control that is being customized.
/// </summary>
private IGrid Grid { get; set; }

/// <summary>
/// Method invoked when the component is ready to start, having received its
/// initial parameters from its parent in the render tree.
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
this.Disposables.Add(this.WhenAnyValue(x => x.ViewModel.ParameterTypeSelector.SelectedParameterType).Subscribe(_ => this.InvokeAsync(this.StateHasChanged)));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
::ng-deep .dx-datagrid-rowsview .dx-selection.dx-row:not(.dx-row-focused):not(.dx-row-removed) > td {
background-color: orange;
color: unset;
}

::ng-deep .dx-datagrid-rowsview .dx-row-focused.dx-data-row .dx-command-edit:not(.dx-focused) .dx-link,
::ng-deep .dx-datagrid-rowsview .dx-row-focused.dx-data-row > td:not(.dx-focused),
::ng-deep .dx-datagrid-rowsview .dx-row-focused.dx-data-row > tr > td:not(.dx-focused) {
background-color: red;
color: #fff;
}

::ng-deep .dx-datagrid-rowsview .dx-row-focused.dx-data-row > td,
::ng-deep .dx-datagrid-rowsview .dx-row-focused.dx-data-row > tr:last-child > td {
border-bottom: 1px solid yellow;
}

.table-container {
min-width: 1400px;
margin-top: 15px;
max-height: 80vh;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
------------------------------------------------------------------------------->
@using COMETwebapp.Utilities
@using COMETwebapp.Extensions
@using COMETwebapp.Components.ParameterEditor.BatchParameterEditor

@inherits COMET.Web.Common.Components.Applications.SingleIterationApplicationBase<COMETwebapp.ViewModels.Components.ParameterEditor.IParameterEditorBodyViewModel>

<LoadingComponent IsVisible="@this.ViewModel.IsLoading">
Expand Down Expand Up @@ -51,6 +53,7 @@
</div>
</div>
<div class="row">
<BatchParameterEditor ViewModel="@(this.ViewModel.BatchParameterEditorViewModel)"/>
<ParameterTable ViewModel="this.ViewModel.ParameterTableViewModel"/>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions COMETwebapp/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace COMETwebapp.Extensions
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileHandler;
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FileRevisionHandler;
using COMETwebapp.ViewModels.Components.EngineeringModel.FileStore.FolderHandler;
using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor;

/// <summary>
/// Extension class for the <see cref="IServiceCollection" />
Expand Down Expand Up @@ -119,6 +120,7 @@ public static void RegisterViewModels(this IServiceCollection serviceCollection)
serviceCollection.AddTransient<IFileHandlerViewModel, FileHandlerViewModel>();
serviceCollection.AddTransient<IFolderHandlerViewModel, FolderHandlerViewModel>();
serviceCollection.AddTransient<IFileRevisionHandlerViewModel, FileRevisionHandlerViewModel>();
serviceCollection.AddTransient<IBatchParameterEditorViewModel, BatchParameterEditorViewModel>();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BatchParameterEditorViewModel.cs" company="RHEA System S.A.">
// Copyright (c) 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 COMET WEB Community Edition
// The COMET WEB Community Edition is the RHEA 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>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor
{
using CDP4Common.EngineeringModelData;
using CDP4Common.Types;

using CDP4Dal;

using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.Utilities.DisposableObject;
using COMET.Web.Common.ViewModels.Components.ParameterEditors;
using COMET.Web.Common.ViewModels.Components.Selectors;

using ReactiveUI;

/// <summary>
/// ViewModel used to apply batch operations for a parameter
/// </summary>
public class BatchParameterEditorViewModel : DisposableObject, IBatchParameterEditorViewModel
{
/// <summary>
/// Creates a new instance of type <see cref="BatchParameterEditorViewModel" />
/// </summary>
/// <param name="sessionService">The <see cref="ISessionService"/></param>
/// <param name="messageBus">The <see cref="ICDPMessageBus"/></param>
public BatchParameterEditorViewModel(ISessionService sessionService, ICDPMessageBus messageBus)
{
this.SessionService = sessionService;

var valueSet = new ParameterValueSet()
{
ValueSwitch = ParameterSwitchKind.MANUAL,
Manual = new ValueArray<string>(["-"])
};

this.Disposables.Add(this.WhenAnyValue(x => x.ParameterTypeSelector.SelectedParameterType).Subscribe(selectedParameterType =>
{
this.ParameterTypeEditorSelectorViewModel = new ParameterTypeEditorSelectorViewModel(selectedParameterType, valueSet, false, messageBus, 0);
}));
}

/// <summary>
/// Gets the current <see cref="Iteration"/>
/// </summary>
public Iteration CurrentIteration { get; private set; }

/// <summary>
/// Gets the <see cref="ISessionService"/>
/// </summary>
public ISessionService SessionService { get; private set; }

/// <summary>
/// Gets the <see cref="IParameterTypeEditorSelectorViewModel" />
/// </summary>
public IParameterTypeEditorSelectorViewModel ParameterTypeEditorSelectorViewModel { get; private set; }

/// <summary>
/// Gets the <see cref="IParameterTypeSelectorViewModel" />
/// </summary>
public IParameterTypeSelectorViewModel ParameterTypeSelector { get; private set; } = new ParameterTypeSelectorViewModel();

/// <summary>
/// Sets the current iteration
/// </summary>
/// <param name="iteration">The iteration to be set</param>
public void SetCurrentIteration(Iteration iteration)
{
this.CurrentIteration = iteration;
this.ParameterTypeSelector.CurrentIteration = iteration;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IBatchParameterEditorViewModel.cs" company="RHEA System S.A.">
// Copyright (c) 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 COMET WEB Community Edition
// The COMET WEB Community Edition is the RHEA 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>
// --------------------------------------------------------------------------------------------------------------------

namespace COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor
{
using CDP4Common.EngineeringModelData;

using COMET.Web.Common.ViewModels.Components.ParameterEditors;
using COMET.Web.Common.ViewModels.Components.Selectors;

/// <summary>
/// ViewModel used to apply batch operations for a parameter
/// </summary>
public interface IBatchParameterEditorViewModel
{
/// <summary>
/// Gets the <see cref="IParameterTypeEditorSelectorViewModel" />
/// </summary>
IParameterTypeEditorSelectorViewModel ParameterTypeEditorSelectorViewModel { get; }

/// <summary>
/// Gets the <see cref="IParameterTypeSelectorViewModel" />
/// </summary>
IParameterTypeSelectorViewModel ParameterTypeSelector { get; }

/// <summary>
/// Sets the current iteration
/// </summary>
/// <param name="iteration">The iteration to be set</param>
void SetCurrentIteration(Iteration iteration);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor
using COMET.Web.Common.ViewModels.Components.Selectors;

using COMETwebapp.Services.SubscriptionService;
using COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor;

/// <summary>
/// View Model that handle the logic for the Parameter Editor application
Expand Down Expand Up @@ -63,5 +64,10 @@ public interface IParameterEditorBodyViewModel : ISingleIterationApplicationBase
/// Gets or sets the <see cref="IParameterTableViewModel" />
/// </summary>
public IParameterTableViewModel ParameterTableViewModel { get; set; }

/// <summary>
/// Gets or sets the <see cref="IBatchParameterEditorViewModel" />
/// </summary>
IBatchParameterEditorViewModel BatchParameterEditorViewModel { get; set; }
}
}
Loading

0 comments on commit b082fdb

Please sign in to comment.