Skip to content

Commit

Permalink
solved issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Jul 29, 2024
1 parent f4341b2 commit b0dc601
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<DxGrid @ref="this.Grid"
CssClass="default-grid"
ShowAllRows="true"
Data="@this.sortedCollection"
Data="@this.ViewModel.Rows.Items.Order(this.comparer)"
SelectionMode="GridSelectionMode.Single"
AllowSelectRowByClick="false"
ShowFilterRow="true"
Expand Down
39 changes: 12 additions & 27 deletions COMETwebapp/Components/ParameterEditor/ParameterTable.razor.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ParameterTable.cs" company="Starion Group S.A.">
// Copyright (c) 2023-2024 Starion Group S.A.
// <copyright file="ParameterTable.razor.cs" company="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 All @@ -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;
Expand All @@ -53,12 +48,7 @@ public partial class ParameterTable
/// <summary>
/// The <see cref="ParameterBaseRowViewModelComparer" />
/// </summary>
private ParameterBaseRowViewModelComparer comparer = new();

/// <summary>
/// The sorted collection of <see cref="ParameterBaseRowViewModel" />
/// </summary>
private ReadOnlyObservableCollection<ParameterBaseRowViewModel> sortedCollection;
private readonly ParameterBaseRowViewModelComparer comparer = new();

/// <summary>
/// Gets or sets the <see cref="IParameterTableViewModel" />
Expand All @@ -80,20 +70,15 @@ 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; });
}

/// <summary>
/// Customizes the table rows
/// </summary>
/// <param name="e">The <see cref="GridCustomizeElementEventArgs"/></param>
/// <param name="e">The <see cref="GridCustomizeElementEventArgs" /></param>
private void OnCustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType == GridElementType.DataRow)
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public bool IsOwnedParameters
/// <returns>A <see cref="Task" /></returns>
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;
}
Expand Down

0 comments on commit b0dc601

Please sign in to comment.