diff --git a/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor b/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor index e350f918..d674e138 100644 --- a/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor +++ b/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor @@ -20,6 +20,8 @@ Copyright (c) 2024 Starion Group S.A. along with this program. If not, see . -------------------------------------------------------------------------------> +@using COMETwebapp.ViewModels.Components.ParameterEditor +@using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues @inherits DisposableComponent + HeaderText="Batch Update" + Width="70vw"> + + @if (this.ViewModel.ParameterTypeSelectorViewModel.SelectedParameterType != null) {
-
Select a value
+
Select a value:
} - + + + + + + + + + + + + + + +
The public ParameterValueSetBaseRowViewModel(ParameterValueSetBase valueSet) { + this.ParameterValueSetBase = valueSet; this.ElementName = ((ElementBase)valueSet.Container.Container).Name; var parameter = (ParameterOrOverrideBase)valueSet.Container; this.ParameterName = parameter.ParameterType.Name; @@ -58,6 +59,11 @@ public ParameterValueSetBaseRowViewModel(ParameterValueSetBase valueSet) this.Scale = parameter.Scale; } + /// + /// The + /// + public ParameterValueSetBase ParameterValueSetBase { get; } + /// /// The /// diff --git a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs index 270e25f7..9248a8c0 100644 --- a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs @@ -37,10 +37,19 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor using COMET.Web.Common.ViewModels.Components.ParameterEditors; using COMET.Web.Common.ViewModels.Components.Selectors; + using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues; + + using DynamicData; + using Microsoft.AspNetCore.Components; using ReactiveUI; + //TODO + // Need to make the user select the value sets available to update for each parameter/element definition, because it depends on the actual state and the option + // Use a grid to display the selection => filters with options and + // Exclude the parameter types SFPT, Array and Compound + /// /// ViewModel used to apply batch operations for a parameter /// @@ -66,6 +75,11 @@ public class BatchParameterEditorViewModel : BelongsToIterationSelectorViewModel /// private readonly ICDPMessageBus messageBus; + /// + /// Gets the excluded s for applying the batch updates + /// + private IEnumerable excludedParameterTypes = [ClassKind.SampledFunctionParameterType, ClassKind.ArrayParameterType, ClassKind.CompoundParameterType]; + /// /// Creates a new instance of type /// @@ -119,11 +133,21 @@ public bool IsLoading /// public IParameterTypeSelectorViewModel ParameterTypeSelectorViewModel { get; private set; } = new ParameterTypeSelectorViewModel(); + /// + /// Gets the + /// + public IOptionSelectorViewModel OptionSelectorViewModel { get; private set; } = new OptionSelectorViewModel(); + /// /// Gets the /// public IConfirmCancelPopupViewModel ConfirmCancelPopupViewModel { get; private set; } + /// + /// Gets the list of s + /// + public SourceList Rows { get; private set; } = new(); + /// /// Updates this view model properties /// @@ -150,17 +174,11 @@ private async Task OnConfirmPopup() this.IsVisible = false; this.logger.LogInformation("Applying manual value {value} to all parameters types with iid {iid}", this.SelectedValueSet.Manual, this.ParameterTypeSelectorViewModel.SelectedParameterType.Iid); - - var parameters = this.CurrentIteration - .QueryParameterAndOverrideBases() - .Where(x => x.ParameterType.Iid == this.ParameterTypeSelectorViewModel.SelectedParameterType.Iid); - var thingsToUpdate = new List(); - foreach (var parameter in parameters) + foreach (var parameterValueSet in this.Rows.Items.Select(x => x.ParameterValueSetBase)) { - var valueSet = (ParameterValueSetBase)parameter.ValueSets.First(); - var valueSetClone = valueSet.Clone(true); + var valueSetClone = parameterValueSet.Clone(true); valueSetClone.Manual = this.SelectedValueSet.Manual; thingsToUpdate.Add(valueSetClone); } @@ -184,6 +202,18 @@ private void OnSelectedParameterTypeChange(ParameterType selectedParameterType) this.SelectedValueSet = defaultParameterValueSet; + var parameterValueSets = this.CurrentIteration? + .QueryParameterAndOverrideBases() + .Where(x => x.ParameterType.Iid == selectedParameterType.Iid) + .Cast() + .SelectMany(x => x.ValueSet); + + this.Rows.Edit(action => + { + action.Clear(); + action.AddRange(parameterValueSets?.Select(x => new ParameterValueSetBaseRowViewModel(x)) ?? Array.Empty()); + }); + this.ParameterTypeEditorSelectorViewModel = new ParameterTypeEditorSelectorViewModel(selectedParameterType, defaultParameterValueSet, false, this.messageBus) { ParameterValueChanged = new EventCallbackFactory().Create<(IValueSet, int)>(this, callbackValueSet => { this.SelectedValueSet = callbackValueSet.Item1; }) diff --git a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs index ce4f358a..4632e67a 100644 --- a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs @@ -28,6 +28,10 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor using COMET.Web.Common.ViewModels.Components.ParameterEditors; using COMET.Web.Common.ViewModels.Components.Selectors; + using COMETwebapp.ViewModels.Components.ModelDashboard.ParameterValues; + + using DynamicData; + /// /// ViewModel used to apply batch operations for a parameter /// @@ -57,5 +61,15 @@ public interface IBatchParameterEditorViewModel : IBelongsToIterationSelectorVie /// Gets or sets the loading value /// bool IsLoading { get; set; } + + /// + /// Gets the + /// + IOptionSelectorViewModel OptionSelectorViewModel { get; } + + /// + /// Gets the list of s + /// + SourceList Rows { get; } } }