diff --git a/COMET.Web.Common/Components/Selectors/DomainOfExpertiseSelector.razor b/COMET.Web.Common/Components/Selectors/DomainOfExpertiseSelector.razor index c91fdd61..88cb68cf 100644 --- a/COMET.Web.Common/Components/Selectors/DomainOfExpertiseSelector.razor +++ b/COMET.Web.Common/Components/Selectors/DomainOfExpertiseSelector.razor @@ -32,7 +32,7 @@ @@ -48,6 +48,10 @@ @(domainOfExpertise.GetSelectorNameAndShortname()) } + else + { + @("Select a Domain Of Expertise") + } -} \ No newline at end of file +} diff --git a/COMET.Web.Common/ViewModels/Components/Selectors/DomainOfExpertiseSelectorViewModel.cs b/COMET.Web.Common/ViewModels/Components/Selectors/DomainOfExpertiseSelectorViewModel.cs index 011f6074..5650f076 100644 --- a/COMET.Web.Common/ViewModels/Components/Selectors/DomainOfExpertiseSelectorViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/Selectors/DomainOfExpertiseSelectorViewModel.cs @@ -51,7 +51,7 @@ public class DomainOfExpertiseSelectorViewModel : BelongsToIterationSelectorView /// Creates a new instance of /// /// The - /// The + /// The public DomainOfExpertiseSelectorViewModel(ISessionService sessionService, ICDPMessageBus messageBus) { this.SessionService = sessionService; @@ -62,7 +62,12 @@ public DomainOfExpertiseSelectorViewModel(ISessionService sessionService, ICDPMe } /// - /// Gets or sets the callback that is executed when the property has changed + /// Gets or sets the condition to check if a null selection can be allowed + /// + public bool AllowNullSelection { get; set; } + + /// + /// Gets or sets the callback that is executed when the property has changed /// public EventCallback OnSelectedDomainOfExpertiseChange { get; set; } @@ -91,11 +96,11 @@ public DomainOfExpertise SelectedDomainOfExpertise } /// - /// Sets the property or resets its value + /// Sets the property or resets its value /// /// The condition to check if the value should be reset - /// The to be set - /// A + /// The to be set + /// A public async Task SetSelectedDomainOfExpertiseOrReset(bool reset, DomainOfExpertise domainOfExpertise = null) { switch (reset) @@ -124,7 +129,7 @@ protected override void UpdateProperties() /// /// Method executed when an iteration domain has changed /// - /// The data + /// The data private void OnDomainChanged(DomainChangedEvent domainChangedEvent) { if (domainChangedEvent.Iteration.Iid == this.CurrentIteration?.Iid) diff --git a/COMET.Web.Common/ViewModels/Components/Selectors/IDomainOfExpertiseSelectorViewModel.cs b/COMET.Web.Common/ViewModels/Components/Selectors/IDomainOfExpertiseSelectorViewModel.cs index 5af1a87b..97395f66 100644 --- a/COMET.Web.Common/ViewModels/Components/Selectors/IDomainOfExpertiseSelectorViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/Selectors/IDomainOfExpertiseSelectorViewModel.cs @@ -52,21 +52,26 @@ public interface IDomainOfExpertiseSelectorViewModel : IBelongsToIterationSelect ISessionService SessionService { get; } /// - /// Gets the from the current + /// Gets the from the current /// DomainOfExpertise CurrentIterationDomain { get; set; } /// - /// Gets or sets the callback that is executed when the property has changed + /// Gets or sets the callback that is executed when the property has changed /// EventCallback OnSelectedDomainOfExpertiseChange { get; set; } /// - /// Sets the property or resets its value + /// Gets or sets the condition to check if a null selection can be allowed + /// + bool AllowNullSelection { get; set; } + + /// + /// Sets the property or resets its value /// /// The condition to check if the value should be reset - /// The to be set - /// A + /// The to be set + /// A Task SetSelectedDomainOfExpertiseOrReset(bool reset, DomainOfExpertise domainOfExpertise = null); } } diff --git a/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor b/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor index 64434d80..e3bd5b19 100644 --- a/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor +++ b/COMETwebapp/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditor.razor @@ -38,7 +38,7 @@ Copyright (c) 2024 Starion Group S.A. @if (this.ViewModel.ParameterTypeSelectorViewModel.SelectedParameterType != null) { -
+
@@ -47,6 +47,23 @@ Copyright (c) 2024 Starion Group S.A.
+
+
+
Filter on Category:
+ +
+
+ +
+
+
Select a value:
x.ViewModel.ParameterTypeSelectorViewModel.SelectedParameterType, x => x.ViewModel.OptionSelectorViewModel.SelectedOption, - x => x.ViewModel.FiniteStateSelectorViewModel.SelectedActualFiniteState) + x => x.ViewModel.FiniteStateSelectorViewModel.SelectedActualFiniteState, + x => x.ViewModel.SelectedCategory, + x => x.ViewModel.DomainOfExpertiseSelectorViewModel.SelectedDomainOfExpertise) .SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); } /// - /// Gets the group check value based on the given + /// Gets the group check value based on the given /// /// The column group context /// The check box value @@ -106,9 +108,9 @@ private void GroupCheckBox_CheckedChanged(bool? value, GridDataColumnGroupRowTem } /// - /// Gets the s from the selected element name group + /// Gets the s from the selected element name group /// - /// The + /// The /// A collection of data items contained in the given group private IEnumerable GetGroupDataItems(GridDataColumnGroupRowTemplateContext context) { diff --git a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs index 5ebe1336..97092fee 100644 --- a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/BatchParameterEditorViewModel.cs @@ -50,25 +50,30 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor /// public class BatchParameterEditorViewModel : BelongsToIterationSelectorViewModel, IBatchParameterEditorViewModel { + /// + /// Gets the excluded s for applying the batch updates + /// + private readonly IEnumerable excludedParameterTypes = [ClassKind.SampledFunctionParameterType, ClassKind.ArrayParameterType, ClassKind.CompoundParameterType]; + /// /// Gets the /// private readonly ILogger logger; /// - /// Gets the + /// Gets the /// private readonly ICDPMessageBus messageBus; /// - /// Gets the excluded s for applying the batch updates + /// The backing field for /// - private readonly IEnumerable excludedParameterTypes = [ClassKind.SampledFunctionParameterType, ClassKind.ArrayParameterType, ClassKind.CompoundParameterType]; + private bool isLoading; /// - /// The backing field for + /// The backing field for /// - private bool isLoading; + private Category selectedCategory; /// /// Creates a new instance of type @@ -83,6 +88,12 @@ public BatchParameterEditorViewModel(ISessionService sessionService, ICDPMessage this.logger = logger; var eventCallbackFactory = new EventCallbackFactory(); + this.DomainOfExpertiseSelectorViewModel = new DomainOfExpertiseSelectorViewModel(sessionService, messageBus) + { + AllowNullSelection = true, + CurrentIteration = this.CurrentIteration + }; + this.ConfirmCancelPopupViewModel = new ConfirmCancelPopupViewModel { OnCancel = eventCallbackFactory.Create(this, this.OnCancelPopup), @@ -92,10 +103,12 @@ public BatchParameterEditorViewModel(ISessionService sessionService, ICDPMessage }; this.Disposables.Add(this.WhenAnyValue(x => x.ParameterTypeSelectorViewModel.SelectedParameterType).Subscribe(this.OnSelectedParameterTypeChange)); - + this.Disposables.Add(this.WhenAnyValue( - x => x.OptionSelectorViewModel.SelectedOption, - x => x.FiniteStateSelectorViewModel.SelectedActualFiniteState) + x => x.OptionSelectorViewModel.SelectedOption, + x => x.FiniteStateSelectorViewModel.SelectedActualFiniteState, + x => x.DomainOfExpertiseSelectorViewModel.SelectedDomainOfExpertise, + x => x.SelectedCategory) .Subscribe(_ => this.ApplyFilters())); } @@ -118,6 +131,20 @@ public bool IsLoading set => this.RaiseAndSetIfChanged(ref this.isLoading, value); } + /// + /// Gets a collection of all available categories + /// + public IEnumerable AvailableCategories => this.SessionService.GetSiteDirectory().AvailableReferenceDataLibraries().SelectMany(x => x.DefinedCategory).Distinct(); + + /// + /// Gets or sets the selected category + /// + public Category SelectedCategory + { + get => this.selectedCategory; + set => this.RaiseAndSetIfChanged(ref this.selectedCategory, value); + } + /// /// Gets the /// @@ -138,13 +165,18 @@ public bool IsLoading /// public IFiniteStateSelectorViewModel FiniteStateSelectorViewModel { get; private set; } = new FiniteStateSelectorViewModel(); + /// + /// Gets the + /// + public IDomainOfExpertiseSelectorViewModel DomainOfExpertiseSelectorViewModel { get; private set; } + /// /// Gets the /// public IConfirmCancelPopupViewModel ConfirmCancelPopupViewModel { get; private set; } /// - /// Gets the list of s + /// Gets the list of s /// public SourceList Rows { get; private set; } = new(); @@ -161,6 +193,8 @@ public void OpenPopup() this.ParameterTypeSelectorViewModel.SelectedParameterType = null; this.OptionSelectorViewModel.SelectedOption = null; this.FiniteStateSelectorViewModel.SelectedActualFiniteState = null; + this.DomainOfExpertiseSelectorViewModel.SelectedDomainOfExpertise = null; + this.SelectedCategory = null; this.SelectedValueSetsRowsToUpdate = []; this.IsVisible = true; } @@ -173,6 +207,7 @@ protected override void UpdateProperties() this.ParameterTypeSelectorViewModel.CurrentIteration = this.CurrentIteration; this.OptionSelectorViewModel.CurrentIteration = this.CurrentIteration; this.FiniteStateSelectorViewModel.CurrentIteration = this.CurrentIteration; + this.DomainOfExpertiseSelectorViewModel.CurrentIteration = this.CurrentIteration; var availableParameterTypeIids = this.CurrentIteration? .QueryParameterAndOverrideBases() @@ -194,7 +229,7 @@ private void OnCancelPopup() /// /// Method executed everytime the is confirmed /// - /// A + /// A private async Task OnConfirmPopup() { this.IsLoading = true; @@ -233,7 +268,7 @@ private void OnSelectedParameterTypeChange(ParameterType selectedParameterType) } /// - /// Applies the selected filters for the + /// Applies the selected filters for the /// private void ApplyFilters() { @@ -244,11 +279,13 @@ private void ApplyFilters() return; } - if (this.ParameterTypeSelectorViewModel.SelectedParameterType != null) + if (this.ParameterTypeSelectorViewModel.SelectedParameterType == null) { - parameterAndOverrideBases = parameterAndOverrideBases.Where(x => x.ParameterType.Iid == this.ParameterTypeSelectorViewModel.SelectedParameterType.Iid); + return; } + parameterAndOverrideBases = parameterAndOverrideBases.Where(x => x.ParameterType.Iid == this.ParameterTypeSelectorViewModel.SelectedParameterType.Iid); + var parameterValueSets = parameterAndOverrideBases .OfType() .SelectMany(x => x.ValueSet); @@ -263,6 +300,20 @@ private void ApplyFilters() parameterValueSets = parameterValueSets.Where(x => x.ActualState?.Iid == this.FiniteStateSelectorViewModel.SelectedActualFiniteState.Iid); } + if (this.SelectedCategory != null) + { + var parameterTypeCategories = this.ParameterTypeSelectorViewModel.SelectedParameterType.Category; + + parameterValueSets = parameterTypeCategories.Count > 0 + ? parameterValueSets.Where(x => x.GetContainerOfType().ParameterType.Category.Contains(this.SelectedCategory)) + : parameterValueSets.Where(x => x.GetContainerOfType().Category.Contains(this.SelectedCategory)); + } + + if (this.DomainOfExpertiseSelectorViewModel.SelectedDomainOfExpertise != null) + { + parameterValueSets = parameterValueSets.Where(x => x.GetContainerOfType().Owner.Iid == this.DomainOfExpertiseSelectorViewModel.SelectedDomainOfExpertise.Iid); + } + this.Rows.Edit(action => { action.Clear(); diff --git a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs index 13d73ed7..34153f03 100644 --- a/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ParameterEditor/BatchParameterEditor/IBatchParameterEditorViewModel.cs @@ -24,6 +24,8 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor.BatchParameterEditor { + using CDP4Common.SiteDirectoryData; + using COMET.Web.Common.ViewModels.Components; using COMET.Web.Common.ViewModels.Components.ParameterEditors; using COMET.Web.Common.ViewModels.Components.Selectors; @@ -68,7 +70,7 @@ public interface IBatchParameterEditorViewModel : IBelongsToIterationSelectorVie IOptionSelectorViewModel OptionSelectorViewModel { get; } /// - /// Gets the list of s + /// Gets the list of s /// SourceList Rows { get; } @@ -82,6 +84,21 @@ public interface IBatchParameterEditorViewModel : IBelongsToIterationSelectorVie /// IReadOnlyList SelectedValueSetsRowsToUpdate { get; set; } + /// + /// Gets a collection of all available categories + /// + IEnumerable AvailableCategories { get; } + + /// + /// Gets or sets the selected category + /// + Category SelectedCategory { get; set; } + + /// + /// Gets the + /// + IDomainOfExpertiseSelectorViewModel DomainOfExpertiseSelectorViewModel { get; } + /// /// Method invoked for opening the batch update popup ///