diff --git a/COMETwebapp.Tests/Components/ModelEditor/ElementDefinitionTableTestFixture.cs b/COMETwebapp.Tests/Components/ModelEditor/ElementDefinitionTableTestFixture.cs index 9ef4ca22..35957e8f 100644 --- a/COMETwebapp.Tests/Components/ModelEditor/ElementDefinitionTableTestFixture.cs +++ b/COMETwebapp.Tests/Components/ModelEditor/ElementDefinitionTableTestFixture.cs @@ -38,8 +38,8 @@ namespace COMETwebapp.Tests.Components.ModelEditor using COMETwebapp.Services.Interoperability; using COMETwebapp.ViewModels.Components.ModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; + using COMETwebapp.ViewModels.Components.ModelEditor.Rows; using COMETwebapp.ViewModels.Components.SystemRepresentation; - using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; using DevExpress.Blazor; @@ -66,28 +66,36 @@ public void SetUp() { this.context = new TestContext(); this.context.ConfigureDevExpressBlazor(); - this.context.Services.AddSingleton(); - this.context.Services.AddSingleton(); + var configuration = new Mock(); configuration.Setup(x => x.ServerConfiguration).Returns(new ServerConfiguration()); - this.context.Services.AddSingleton(configuration.Object); + var elementDefinition = new ElementDefinition(); - this.elementDefinitionDetailsViewModel = new ElementDefinitionDetailsViewModel(); + var row = new ElementDefinitionRowViewModel + { + ElementDefinitionName = "Test1", + ElementBase = elementDefinition, + IsTopElement = true + }; + this.elementDefinitionDetailsViewModel = new ElementDefinitionDetailsViewModel(); this.addParameterViewModel = new Mock(); this.addParameterViewModel.Setup(x => x.ParameterTypeSelectorViewModel).Returns(new ParameterTypeSelectorViewModel()); this.elementDefinitionTableViewModel = new Mock(); - this.elementDefinitionTableViewModel.Setup(x => x.RowsTarget).Returns([new ElementDefinitionRowViewModel { ElementDefinitionName = "Test" }]); - this.elementDefinitionTableViewModel.Setup(x => x.RowsSource).Returns([new ElementDefinitionRowViewModel { ElementDefinitionName = "Test1" }]); + this.elementDefinitionTableViewModel.Setup(x => x.RowsTarget).Returns([row]); + this.elementDefinitionTableViewModel.Setup(x => x.RowsSource).Returns([row]); this.elementDefinitionTableViewModel.Setup(x => x.ElementDefinitionDetailsViewModel).Returns(this.elementDefinitionDetailsViewModel); this.elementDefinitionTableViewModel.Setup(x => x.AddParameterViewModel).Returns(this.addParameterViewModel.Object); this.elementDefinitionTableViewModel.Setup(x => x.SelectedElementDefinition).Returns(new ElementDefinition()); + this.elementDefinitionTableViewModel.Setup(x => x.IsLoading).Returns(false); + this.context.Services.AddSingleton(configuration.Object); this.context.Services.AddSingleton(this.elementDefinitionTableViewModel.Object); + this.context.Services.AddSingleton(); + this.context.Services.AddSingleton(); this.renderedComponent = this.context.RenderComponent(); - this.table = this.renderedComponent.Instance; } @@ -131,6 +139,48 @@ public void VerifyComponent() }); } + [Test] + public void VerifyElementSelection() + { + var sourceGrid = this.renderedComponent.FindComponent(); + var targetGrid = this.renderedComponent.FindComponents()[1]; + + Assert.Multiple(() => + { + Assert.That(sourceGrid.Instance.SelectedDataItem, Is.Null); + Assert.That(targetGrid.Instance.SelectedDataItem, Is.Null); + }); + + var firstSourceRow = sourceGrid.Find(".dxbl-grid-group-row").Children[1]; + firstSourceRow.Click(); + + Assert.Multiple(() => + { + this.elementDefinitionTableViewModel.Verify(x => x.SelectElement(It.IsAny()), Times.Once); + Assert.That(sourceGrid.Instance.SelectedDataItem, Is.Not.Null); + Assert.That(targetGrid.Instance.SelectedDataItem, Is.Null); + }); + + var firstTargetRow = targetGrid.Find(".dxbl-grid-group-row").Children[1]; + firstTargetRow.Click(); + + Assert.Multiple(() => + { + this.elementDefinitionTableViewModel.Verify(x => x.SelectElement(It.IsAny()), Times.Exactly(2)); + Assert.That(sourceGrid.Instance.SelectedDataItem, Is.Null); + Assert.That(targetGrid.Instance.SelectedDataItem, Is.Not.Null); + }); + + firstSourceRow.Click(); + + Assert.Multiple(() => + { + this.elementDefinitionTableViewModel.Verify(x => x.SelectElement(It.IsAny()), Times.Exactly(3)); + Assert.That(sourceGrid.Instance.SelectedDataItem, Is.Not.Null); + Assert.That(targetGrid.Instance.SelectedDataItem, Is.Null); + }); + } + [Test] public void VerifyMoveGridRow() { diff --git a/COMETwebapp.Tests/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModelTestFixture.cs b/COMETwebapp.Tests/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModelTestFixture.cs index aa19b4ff..4bf03729 100644 --- a/COMETwebapp.Tests/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModelTestFixture.cs +++ b/COMETwebapp.Tests/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModelTestFixture.cs @@ -35,7 +35,6 @@ namespace COMETwebapp.Tests.ViewModels.Components.ModelEditor using COMET.Web.Common.Services.SessionManagement; using COMETwebapp.ViewModels.Components.ModelEditor; - using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; using DynamicData; @@ -99,7 +98,11 @@ public void Setup() this.iteration = new Iteration { Iid = Guid.NewGuid(), - Element = { topElement, elementDefinition } + Element = { topElement, elementDefinition }, + Container = new EngineeringModel + { + EngineeringModelSetup = new EngineeringModelSetup() + } }; var iterations = new SourceList(); @@ -169,12 +172,15 @@ public void VerifyInitializeViewModel() [Test] public void VerifyRecordChange() { + this.viewModel.SelectElement(this.iteration.Element[0]); + this.messageBus.SendMessage(SessionServiceEvent.SessionRefreshed, this.sessionService.Object.Session); Assert.That(this.viewModel.RowsSource, Has.Count.EqualTo(3)); var elementDefinition = new ElementDefinition { - Iid = Guid.NewGuid() + Iid = Guid.NewGuid(), + Name = "new element" }; this.iteration.Element.Add(elementDefinition); @@ -188,6 +194,11 @@ public void VerifyRecordChange() this.messageBus.SendMessage(SessionServiceEvent.SessionRefreshed, this.sessionService.Object.Session); Assert.That(this.viewModel.RowsSource, Has.Count.EqualTo(3)); + + elementDefinition.Iid = this.viewModel.SelectedElementDefinition.Iid; + this.messageBus.SendObjectChangeEvent(this.viewModel.RowsSource[0].ElementBase, EventKind.Updated); + this.messageBus.SendMessage(SessionServiceEvent.SessionRefreshed, this.sessionService.Object.Session); + Assert.That(this.viewModel.ElementDefinitionDetailsViewModel.Rows, Is.Not.Null); } [Test] @@ -215,8 +226,7 @@ public void VerifySelectElement() } }; - var row = new ElementDefinitionRowViewModel(elementDefinition); - this.viewModel.SelectElement(row); + this.viewModel.SelectElement(elementDefinition); Assert.That(this.viewModel.SelectedElementDefinition, Is.EqualTo(elementDefinition)); var usage = new ElementUsage @@ -225,8 +235,7 @@ public void VerifySelectElement() Container = elementDefinition }; - row = new ElementDefinitionRowViewModel(usage); - this.viewModel.SelectElement(row); + this.viewModel.SelectElement(usage); Assert.That(this.viewModel.SelectedElementDefinition, Is.EqualTo(usage.ElementDefinition)); this.viewModel.OpenAddParameterPopup(); diff --git a/COMETwebapp/Components/Common/DataItemDetailsComponent.razor b/COMETwebapp/Components/Common/DataItemDetailsComponent.razor index e40356c5..3ad6efe3 100644 --- a/COMETwebapp/Components/Common/DataItemDetailsComponent.razor +++ b/COMETwebapp/Components/Common/DataItemDetailsComponent.razor @@ -17,7 +17,7 @@ Copyright (c) 2023-2024 Starion Group S.A. @namespace COMETwebapp.Components.Common -
+
@if (this.IsSelected) { @@ -27,7 +27,7 @@ Copyright (c) 2023-2024 Starion Group S.A. {
-
Select an item to view or edit, or click add to create
+
@this.NotSelectedText
Comet Web
diff --git a/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.cs b/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.cs index 2bb92a5e..7fb72554 100644 --- a/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.cs +++ b/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.cs @@ -54,5 +54,17 @@ public partial class DataItemDetailsComponent /// [Parameter] public Action OnButtonClick { get; set; } + + /// + /// Gets or sets the text to be displayed when the property is set to false + /// + [Parameter] + public string NotSelectedText { get; set; } = "Select an item to view or edit, or click add to create"; + + /// + /// Gets or sets the width of the panel container + /// + [Parameter] + public string Width { get; set; } = "50%"; } } diff --git a/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.css b/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.css index a1c0ef73..dc20dfd3 100644 --- a/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.css +++ b/COMETwebapp/Components/Common/DataItemDetailsComponent.razor.css @@ -7,7 +7,6 @@ } .data-items-panel-container { - width: 50%; max-height: 85vh; position: sticky; top: 0px; diff --git a/COMETwebapp/Components/ModelEditor/DetailsPanelEditor.razor b/COMETwebapp/Components/ModelEditor/DetailsPanelEditor.razor index ceb74128..2d260b0e 100644 --- a/COMETwebapp/Components/ModelEditor/DetailsPanelEditor.razor +++ b/COMETwebapp/Components/ModelEditor/DetailsPanelEditor.razor @@ -1,7 +1,7 @@  @using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; +@using COMETwebapp.ViewModels.Components.ModelEditor.Rows @inherits SingleIterationApplicationBase;
-
-

Target Model

- - - - - - -
-
+

Source Model

- - - - - - +
+ + + + + + + +
-
-
-

Panel Editor

-
- @if (this.ViewModel.SelectedElementDefinition is not null) - { - - } - - -
+
+

Target Model

+
+ + + + + +
-
-
- +
+ +
+ +
+

Panel Editor

+
+ @if (this.ViewModel.SelectedElementDefinition is not null) + { + + } + + +
-
+
+ +
+
diff --git a/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.cs b/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.cs index 7653bb6f..9864f608 100644 --- a/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.cs +++ b/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.cs @@ -27,7 +27,7 @@ namespace COMETwebapp.Components.ModelEditor using COMET.Web.Common.Extensions; using COMETwebapp.Services.Interoperability; - using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; + using COMETwebapp.ViewModels.Components.ModelEditor.Rows; using DevExpress.Blazor; @@ -183,7 +183,61 @@ private static string GetGridSelector(IGrid grid) private void OnElementSelected(GridRowClickEventArgs args) { var selectedNode = (ElementDefinitionRowViewModel)args.Grid.GetDataItem(args.VisibleIndex); - this.ViewModel.SelectElement(selectedNode); + SetGridSelectedDataItem(args.Grid, selectedNode); + + if (args.Grid == this.FirstGrid) + { + SetGridSelectedDataItem(this.SecondGrid, null); + } + + if (args.Grid == this.SecondGrid) + { + SetGridSelectedDataItem(this.FirstGrid, null); + } + + this.ViewModel.SelectElement(selectedNode.ElementBase); + } + + /// + /// Method invoked to highlight the top element and the selected groups + /// + /// A + private static void OnCustomizeElement(GridCustomizeElementEventArgs e) + { + if (e.ElementType != GridElementType.GroupCell) + { + return; + } + + var isTopElement = (bool)e.Grid.GetRowValue(e.VisibleIndex, nameof(ElementDefinitionRowViewModel.IsTopElement)); + + if (isTopElement) + { + e.CssClass = "font-weight-bold"; + } + + var elementDefinitionName = (string)e.Grid.GetRowValue(e.VisibleIndex, nameof(ElementDefinitionRowViewModel.ElementDefinitionName)); + var selectedElementDefinitionName = (ElementDefinitionRowViewModel)e.Grid.SelectedDataItem; + + var isSubItemSelected = ((IEnumerable)e.Grid.Data) + .Any(x => x.ElementDefinitionName == elementDefinitionName && x.ElementDefinitionName == selectedElementDefinitionName?.ElementDefinitionName); + + if (isSubItemSelected) + { + e.CssClass += " highlighted-item"; + } + } + + /// + /// Sets the selected data item from the given grid + /// + /// The grid to be updated + /// The new data item + private static void SetGridSelectedDataItem(IGrid grid, object dataItem) + { + grid.BeginUpdate(); + grid.SelectedDataItem = dataItem; + grid.EndUpdate(); } } } diff --git a/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.css b/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.css new file mode 100644 index 00000000..c81656e7 --- /dev/null +++ b/COMETwebapp/Components/ModelEditor/ElementDefinitionTable.razor.css @@ -0,0 +1,10 @@ +.model-elements-column { + width: 25vw; +} + +.sticky-scrollable-column { + position: sticky; + top: 0px; + max-height: 80vh; + overflow: auto; +} diff --git a/COMETwebapp/ViewModels/Components/ModelEditor/AddParameterViewModel/AddParameterViewModel.cs b/COMETwebapp/ViewModels/Components/ModelEditor/AddParameterViewModel/AddParameterViewModel.cs index cc04de01..64b0bf45 100644 --- a/COMETwebapp/ViewModels/Components/ModelEditor/AddParameterViewModel/AddParameterViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ModelEditor/AddParameterViewModel/AddParameterViewModel.cs @@ -117,13 +117,18 @@ public AddParameterViewModel(ISessionService sessionService, ICDPMessageBus mess /// public void SetSelectedElementDefinition(ElementDefinition selectedElementDefinition) { + if (selectedElementDefinition is null) + { + return; + } + this.SelectedElementDefinition = selectedElementDefinition; var allParameterTypes = this.CurrentIteration.QueryUsedParameterTypes(); var elementDefinitionParameterTypes = this.SelectedElementDefinition.Parameter.Select(x => x.ParameterType); var filteredParameterTypes = allParameterTypes.Where(x => !elementDefinitionParameterTypes.Contains(x)).Select(x => x.Iid); this.ParameterTypeSelectorViewModel.FilterAvailableParameterTypes(filteredParameterTypes); - + this.DomainOfExpertiseSelectorViewModel.AvailableDomainsOfExpertise = selectedElementDefinition.GetContainerOfType().EngineeringModelSetup.ActiveDomain; this.DomainOfExpertiseSelectorViewModel.SetSelectedDomainOfExpertiseOrReset(true); } diff --git a/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs b/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs index db82098e..39fd187a 100644 --- a/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ModelEditor/ElementDefinitionTableViewModel.cs @@ -37,6 +37,7 @@ namespace COMETwebapp.ViewModels.Components.ModelEditor using COMETwebapp.Components.ModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; + using COMETwebapp.ViewModels.Components.ModelEditor.Rows; using COMETwebapp.ViewModels.Components.SystemRepresentation; using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; @@ -144,15 +145,15 @@ public bool IsOnAddingParameterMode public ElementDefinition SelectedElementDefinition { get; set; } /// - /// set the selected + /// Set the selected /// - /// The selected - public void SelectElement(ElementDefinitionRowViewModel selectedNode) + /// The selected + public void SelectElement(ElementBase selectedElementBase) { // It is preferable to have a selection based on the Iid of the Thing - this.ElementDefinitionDetailsViewModel.SelectedSystemNode = selectedNode.ElementBase; + this.ElementDefinitionDetailsViewModel.SelectedSystemNode = selectedElementBase; - this.SelectedElementDefinition = selectedNode.ElementBase switch + this.SelectedElementDefinition = selectedElementBase switch { ElementDefinition definition => definition, ElementUsage usage => usage.ElementDefinition, @@ -202,11 +203,15 @@ public void UpdateRows(IEnumerable updatedThings) foreach (var element in updatedThings.OfType()) { var row = this.RowsSource.FirstOrDefault(x => x.ElementBase.Iid == element.Iid); - row?.UpdateProperties(new ElementDefinitionRowViewModel(element)); row = this.RowsTarget.FirstOrDefault(x => x.ElementBase.Iid == element.Iid); row?.UpdateProperties(new ElementDefinitionRowViewModel(element)); + + if (element.Iid == this.SelectedElementDefinition.Iid) + { + this.SelectElement(element); + } } } diff --git a/COMETwebapp/ViewModels/Components/ModelEditor/IElementDefinitionTableViewModel.cs b/COMETwebapp/ViewModels/Components/ModelEditor/IElementDefinitionTableViewModel.cs index e3c8595f..2aa97c0f 100644 --- a/COMETwebapp/ViewModels/Components/ModelEditor/IElementDefinitionTableViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ModelEditor/IElementDefinitionTableViewModel.cs @@ -1,18 +1,18 @@ // -------------------------------------------------------------------------------------------------------------------- // -// 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. @@ -32,10 +32,8 @@ namespace COMETwebapp.ViewModels.Components.ModelEditor using COMETwebapp.Components.ModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; + using COMETwebapp.ViewModels.Components.ModelEditor.Rows; using COMETwebapp.ViewModels.Components.SystemRepresentation; - using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; - - using DevExpress.Blazor; /// /// Interface for the @@ -78,7 +76,7 @@ public interface IElementDefinitionTableViewModel : ISingleIterationApplicationB IAddParameterViewModel AddParameterViewModel { get; set; } /// - /// Value indicating the user is currently adding a new to a + /// Value indicating the user is currently adding a new to a /// bool IsOnAddingParameterMode { get; set; } @@ -88,13 +86,13 @@ public interface IElementDefinitionTableViewModel : ISingleIterationApplicationB void OpenCreateElementDefinitionCreationPopup(); /// - /// set the selected + /// Set the selected /// - /// The selected - void SelectElement(ElementDefinitionRowViewModel selectedNode); + /// The selected + void SelectElement(ElementBase selectedElementBase); /// - /// Opens the popup + /// Opens the popup /// void OpenAddParameterPopup(); } diff --git a/COMETwebapp/ViewModels/Components/ModelEditor/Rows/ElementDefinitionRowViewModel.cs b/COMETwebapp/ViewModels/Components/ModelEditor/Rows/ElementDefinitionRowViewModel.cs index f6e1f354..152f7938 100644 --- a/COMETwebapp/ViewModels/Components/ModelEditor/Rows/ElementDefinitionRowViewModel.cs +++ b/COMETwebapp/ViewModels/Components/ModelEditor/Rows/ElementDefinitionRowViewModel.cs @@ -1,18 +1,18 @@ // -------------------------------------------------------------------------------------------------------------------- // -// 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. @@ -22,7 +22,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace COMETwebapp.ViewModels.Components.SystemRepresentation.Rows +namespace COMETwebapp.ViewModels.Components.ModelEditor.Rows { using CDP4Common.EngineeringModelData; @@ -33,6 +33,11 @@ namespace COMETwebapp.ViewModels.Components.SystemRepresentation.Rows /// public class ElementDefinitionRowViewModel : ReactiveObject { + /// + /// Backing field for + /// + private ElementBase elementBase; + /// /// Backing field for /// @@ -44,9 +49,9 @@ public class ElementDefinitionRowViewModel : ReactiveObject private string elementUsageName; /// - /// Backing field for + /// Backing field for /// - private ElementBase elementBase; + private bool isTopElement; /// /// Initializes a new instance of the class. @@ -56,15 +61,19 @@ public ElementDefinitionRowViewModel(ElementBase elementBase) { this.elementBase = elementBase; - if (this.elementBase is ElementDefinition elementDefinition) + switch (this.elementBase) { - this.ElementDefinitionName = elementDefinition.Name; - } - else if (this.elementBase is ElementUsage elementUsage) - { - var elementDefinitionContainer = elementUsage.GetContainerOfType(); - this.ElementDefinitionName = elementDefinitionContainer.Name; - this.ElementUsageName = elementUsage.Name; + case ElementDefinition elementDefinition: + this.ElementDefinitionName = elementDefinition.Name; + this.IsTopElement = elementDefinition == elementDefinition.GetContainerOfType().TopElement; + break; + case ElementUsage elementUsage: + { + var elementDefinitionContainer = elementUsage.GetContainerOfType(); + this.ElementDefinitionName = elementDefinitionContainer.Name; + this.ElementUsageName = elementUsage.Name; + break; + } } } @@ -94,7 +103,7 @@ public string ElementUsageName } /// - /// The + /// The /// public ElementBase ElementBase { @@ -102,6 +111,15 @@ public ElementBase ElementBase set => this.RaiseAndSetIfChanged(ref this.elementBase, value); } + /// + /// The value to check if the element base is the top element + /// + public bool IsTopElement + { + get => this.isTopElement; + set => this.RaiseAndSetIfChanged(ref this.isTopElement, value); + } + /// /// Update this row view model properties /// @@ -111,6 +129,7 @@ public void UpdateProperties(ElementDefinitionRowViewModel elementDefinitionRow) this.ElementBase = elementDefinitionRow.elementBase; this.ElementDefinitionName = elementDefinitionRow.elementDefinitionName; this.ElementUsageName = elementDefinitionRow.elementUsageName; + this.IsTopElement = elementDefinitionRow.isTopElement; } } }