Skip to content

Commit

Permalink
updates to fix wrong behavior when in side panel
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Jul 30, 2024
1 parent 8dc1816 commit b6f19a4
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,33 +242,13 @@ public async Task VerifyApplyFilters()
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.viewModel.ElementSelector.SelectedElementBase = this.viewModel.ElementSelector.AvailableElements.First();
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.DefaultOption, this.viewModel.ElementSelector.SelectedElementBase, null, true), Times.AtLeastOnce);

this.viewModel.ElementSelector.SelectedElementBase = null;
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.viewModel.ParameterTypeSelector.SelectedParameterType = this.viewModel.ParameterTypeSelector.AvailableParameterTypes.First();
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.DefaultOption,
null, this.viewModel.ParameterTypeSelector.SelectedParameterType, true), Times.Once);

this.viewModel.ParameterTypeSelector.SelectedParameterType = null;
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.viewModel.OptionSelector.SelectedOption = this.viewModel.CurrentThing.Option.Last();
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.Option.Last(),
null, null, true), Times.Once);

this.viewModel.IsOwnedParameters = false;
await TaskHelper.WaitWhileAsync(() => this.viewModel.IsLoading);

this.tableViewModel.Verify(x => x.ApplyFilters(this.iteration.Option.Last(),
null, null, false), Times.Once);
this.viewModel.ApplyFilters();

this.tableViewModel.Verify(x => x.ApplyFilters(It.IsAny<Option>(), It.IsAny<ElementBase>(), It.IsAny<ParameterType>(), It.IsAny<bool>()), Times.AtLeastOnce);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
</div>
</div>
</div>
</LoadingComponent>
</LoadingComponent>
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private void UpdateUrl(string pageName = WebAppConstantValues.ModelDashboardPage
additionalParameters[QueryKeys.ParameterKey] = this.ViewModel.ParameterTypeSelector.SelectedParameterType.Iid.ToShortGuid();
}

this.ViewModel.UpdateDashboards();
this.UpdateUrlWithParameters(additionalParameters, pageName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ private void UpdateUrl()
additionalParameters["owned"] = this.ViewModel.IsOwnedParameters.ToString();
}

this.ViewModel.ApplyFilters();
this.UpdateUrlWithParameters(additionalParameters, WebAppConstantValues.ParameterEditorPage);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private void UpdateUrl()
additionalParameters[QueryKeys.ParameterKey] = this.ViewModel.ParameterTypeSelector.SelectedParameterType.Iid.ToShortGuid();
}

this.ViewModel.UpdateTables();
this.UpdateUrlWithParameters(additionalParameters, WebAppConstantValues.SubscriptionDashboardPage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void UpdateUrl()
additionalParameters[QueryKeys.OptionKey] = this.ViewModel.OptionSelector.SelectedOption.Iid.ToShortGuid();
}

this.ViewModel.ApplyFilters();
this.UpdateUrlWithParameters(additionalParameters, WebAppConstantValues.SystemRepresentationPage);
}
}
Expand Down
1 change: 1 addition & 0 deletions COMETwebapp/Components/Viewer/ViewerBody.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private void UpdateUrl()
additionalParameters["option"] = this.ViewModel.OptionSelector.SelectedOption.Iid.ToShortGuid();
}

this.ViewModel.InitializeViewModel();
this.UpdateUrlWithParameters(additionalParameters, WebAppConstantValues.ViewerPage);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ public interface IModelDashboardBodyViewModel : ISingleIterationApplicationBaseV
/// Gets the <see cref="IElementDashboardViewModel" />
/// </summary>
IElementDashboardViewModel ElementDashboard { get; }

/// <summary>
/// Update the dashboard view models properties
/// </summary>
void UpdateDashboards();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ModelDashboardBodyViewModel.cs" company="Starion Group S.A.">
// Copyright (c) 2023-2024 Starion Group S.A.
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Nabil Abbar
// 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.
// 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 CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
// 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 CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
// 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.
Expand All @@ -28,7 +28,6 @@ namespace COMETwebapp.ViewModels.Components.ModelDashboard

using CDP4Dal;

using COMET.Web.Common.Extensions;
using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.ViewModels.Components.Applications;
using COMET.Web.Common.ViewModels.Components.Selectors;
Expand All @@ -52,11 +51,6 @@ public class ModelDashboardBodyViewModel : SingleIterationApplicationBaseViewMod
public ModelDashboardBodyViewModel(ISessionService sessionService, IParameterDashboardViewModel parameterDashboard, ICDPMessageBus messageBus) : base(sessionService, messageBus)
{
this.ParameterDashboard = parameterDashboard;

this.Disposables.Add(this.WhenAnyValue(x => x.FiniteStateSelector.SelectedActualFiniteState,
x => x.OptionSelector.SelectedOption,
x => x.ParameterTypeSelector.SelectedParameterType)
.SubscribeAsync(_ => this.UpdateDashboards()));
}

/// <summary>
Expand Down Expand Up @@ -89,6 +83,22 @@ public ModelDashboardBodyViewModel(ISessionService sessionService, IParameterDas
/// </summary>
public IParameterTypeSelectorViewModel ParameterTypeSelector { get; private set; } = new ParameterTypeSelectorViewModel();

/// <summary>
/// Update the dashboard view models properties
/// </summary>
public void UpdateDashboards()
{
this.IsLoading = true;

this.ParameterDashboard.UpdateProperties(this.CurrentThing, this.OptionSelector.SelectedOption,
this.FiniteStateSelector.SelectedActualFiniteState, this.ParameterTypeSelector.SelectedParameterType,
this.CurrentDomain, this.AvailableDomains);

this.ElementDashboard.UpdateProperties(this.CurrentThing, this.CurrentDomain);

this.IsLoading = false;
}

/// <summary>
/// Handles the refresh of the current <see cref="ISession" />
/// </summary>
Expand All @@ -105,7 +115,7 @@ protected override Task OnSessionRefreshed()
protected override async Task OnDomainChanged()
{
await base.OnDomainChanged();
await this.UpdateDashboards();
this.UpdateDashboards();
}

/// <summary>
Expand All @@ -124,24 +134,7 @@ protected override async Task OnThingChanged()
: this.SessionService.GetModelDomains((EngineeringModelSetup)this.CurrentThing.IterationSetup.Container);

this.CurrentDomain = this.CurrentThing == null ? null : this.SessionService.GetDomainOfExpertise(this.CurrentThing);
await this.UpdateDashboards();
}

/// <summary>
/// Update the dashboard view models properties
/// </summary>
/// <returns>A <see cref="Task" /></returns>
private async Task UpdateDashboards()
{
this.IsLoading = true;
await Task.Delay(1);

this.ParameterDashboard.UpdateProperties(this.CurrentThing, this.OptionSelector.SelectedOption,
this.FiniteStateSelector.SelectedActualFiniteState, this.ParameterTypeSelector.SelectedParameterType,
this.CurrentDomain, this.AvailableDomains);

this.ElementDashboard.UpdateProperties(this.CurrentThing, this.CurrentDomain);
this.IsLoading = false;
this.UpdateDashboards();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IParameterEditorBodyViewModel.cs" company="Starion Group S.A.">
// Copyright (c) 2023-2024 Starion Group S.A.
// Copyright (c) 2024 Starion Group S.A.
//
// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine
// 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.
// 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 CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or
// 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 CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful,
// 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.
Expand Down Expand Up @@ -69,5 +69,10 @@ public interface IParameterEditorBodyViewModel : ISingleIterationApplicationBase
/// Gets or sets the <see cref="IBatchParameterEditorViewModel" />
/// </summary>
IBatchParameterEditorViewModel BatchParameterEditorViewModel { get; set; }

/// <summary>
/// Apply all the filters on the <see cref="IParameterTableViewModel" />
/// </summary>
void ApplyFilters();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor
using CDP4Dal;
using CDP4Dal.Events;

using COMET.Web.Common.Extensions;
using COMET.Web.Common.Services.SessionManagement;
using COMET.Web.Common.ViewModels.Components.Applications;
using COMET.Web.Common.ViewModels.Components.Selectors;
Expand Down Expand Up @@ -75,13 +74,6 @@ public ParameterEditorBodyViewModel(ISessionService sessionService, ISubscriptio
this.ParameterTableViewModel = parameterTableView;
this.BatchParameterEditorViewModel = batchParameterEditorViewModel;

this.Disposables.Add(this.WhenAnyValue(
x => x.ElementSelector.SelectedElementBase,
x => x.OptionSelector.SelectedOption,
x => x.ParameterTypeSelector.SelectedParameterType,
x => x.IsOwnedParameters)
.SubscribeAsync(_ => this.ApplyFilters()));

this.InitializeSubscriptions(ObjectChangedTypesOfInterest);
this.RegisterViewModelsWithReusableRows([this.ParameterTableViewModel]);
}
Expand Down Expand Up @@ -125,6 +117,18 @@ public bool IsOwnedParameters
/// </summary>
public IBatchParameterEditorViewModel BatchParameterEditorViewModel { get; set; }

/// <summary>
/// Apply all the filters on the <see cref="IParameterTableViewModel" />
/// </summary>
public void ApplyFilters()
{
if (this.CurrentThing != null)
{
this.ParameterTableViewModel.ApplyFilters(this.OptionSelector.SelectedOption, this.ElementSelector.SelectedElementBase,
this.ParameterTypeSelector.SelectedParameterType, this.IsOwnedParameters);
}
}

/// <summary>
/// Handles the refresh of the current <see cref="ISession" />
/// </summary>
Expand Down Expand Up @@ -160,7 +164,7 @@ protected override async Task OnDomainChanged()

if (this.IsOwnedParameters)
{
await this.ApplyFilters();
this.ApplyFilters();
}

this.IsLoading = false;
Expand All @@ -187,26 +191,8 @@ protected override async Task OnThingChanged()
}

this.ParameterTableViewModel.InitializeViewModel(this.CurrentThing, this.CurrentDomain, this.OptionSelector.SelectedOption);
await this.ApplyFilters();
this.ApplyFilters();
this.IsLoading = false;
}

/// <summary>
/// Apply all the filters on the <see cref="IParameterTableViewModel" />
/// </summary>
/// <returns>A <see cref="Task" /></returns>
private async Task ApplyFilters()
{
if (this.CurrentThing != null)
{
this.IsLoading = true;
await Task.Delay(1);

this.ParameterTableViewModel.ApplyFilters(this.OptionSelector.SelectedOption, this.ElementSelector.SelectedElementBase,
this.ParameterTypeSelector.SelectedParameterType, this.IsOwnedParameters);

this.IsLoading = false;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@ public interface ISubscriptionDashboardBodyViewModel : ISingleIterationApplicati
/// Gets the <see cref="IParameterTypeSelectorViewModel" />
/// </summary>
IParameterTypeSelectorViewModel ParameterTypeSelector { get; }

/// <summary>
/// Updates the <see cref="ISubscribedTableViewModel" /> and <see cref="IDomainOfExpertiseSubscriptionTableViewModel" />
/// </summary>
/// <returns>A <see cref="Task" /></returns>
void UpdateTables();
}
}
Loading

0 comments on commit b6f19a4

Please sign in to comment.