From b0dc601584f02a9be3f95790b9c3b54333565a99 Mon Sep 17 00:00:00 2001 From: Joao Rua Date: Mon, 29 Jul 2024 15:03:36 +0100 Subject: [PATCH] solved issue --- .../ParameterEditor/ParameterTable.razor | 2 +- .../ParameterEditor/ParameterTable.razor.cs | 39 ++++++------------- .../ParameterEditorBodyViewModel.cs | 2 +- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/COMETwebapp/Components/ParameterEditor/ParameterTable.razor b/COMETwebapp/Components/ParameterEditor/ParameterTable.razor index 77388896..649a4e8a 100644 --- a/COMETwebapp/Components/ParameterEditor/ParameterTable.razor +++ b/COMETwebapp/Components/ParameterEditor/ParameterTable.razor @@ -66,7 +66,7 @@ -// 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. @@ -24,18 +24,13 @@ namespace COMETwebapp.Components.ParameterEditor { - using System.Collections.ObjectModel; - - using CDP4Common.EngineeringModelData; - using CDP4Common.SiteDirectoryData; + using COMET.Web.Common.Extensions; using COMETwebapp.Comparer; using COMETwebapp.ViewModels.Components.ParameterEditor; using DevExpress.Blazor; - using DynamicData; - using Microsoft.AspNetCore.Components; using ReactiveUI; @@ -53,12 +48,7 @@ public partial class ParameterTable /// /// The /// - private ParameterBaseRowViewModelComparer comparer = new(); - - /// - /// The sorted collection of - /// - private ReadOnlyObservableCollection sortedCollection; + private readonly ParameterBaseRowViewModelComparer comparer = new(); /// /// Gets or sets the @@ -80,12 +70,7 @@ protected override void OnInitialized() base.OnInitialized(); this.Disposables.Add(this.WhenAnyValue(x => x.ViewModel.IsOnEditMode) - .Subscribe(_ => this.InvokeAsync(this.StateHasChanged))); - - this.Disposables.Add(this.ViewModel.Rows.Connect() - .Sort(this.comparer) - .Bind(out this.sortedCollection) - .Subscribe(_ => this.InvokeAsync(this.StateHasChanged))); + .SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); this.closeEditor = new EventCallbackFactory().Create(this, () => { this.ViewModel.IsOnEditMode = false; }); } @@ -93,7 +78,7 @@ protected override void OnInitialized() /// /// Customizes the table rows /// - /// The + /// The private void OnCustomizeElement(GridCustomizeElementEventArgs e) { if (e.ElementType == GridElementType.DataRow) @@ -109,7 +94,7 @@ private void OnCustomizeElement(GridCustomizeElementEventArgs e) if (e.ElementType == GridElementType.GroupCell) { var elementBaseName = (string)e.Grid.GetRowValue(e.VisibleIndex, nameof(ParameterBaseRowViewModel.ElementBaseName)); - var isPublishableParameterInGroup = this.sortedCollection.Any(x => x.IsPublishable && x.ElementBaseName == elementBaseName); + var isPublishableParameterInGroup = this.ViewModel.Rows.Items.Any(x => x.IsPublishable && x.ElementBaseName == elementBaseName); if (isPublishableParameterInGroup) { diff --git a/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs b/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs index eadc7a09..3316e45d 100644 --- a/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs @@ -129,7 +129,7 @@ public bool IsOwnedParameters /// A protected override async Task OnSessionRefreshed() { - if (!this.AddedThings.Any() && !this.DeletedThings.Any() && !this.UpdatedThings.Any()) + if (this.AddedThings.Count == 0 && this.DeletedThings.Count == 0 && this.UpdatedThings.Count == 0) { return; }