diff --git a/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor.cs b/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor.cs index f700d27f..8d38a07f 100644 --- a/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor.cs +++ b/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor.cs @@ -48,7 +48,7 @@ public partial class ElementDefinitionTree /// The Iteration /// [Parameter] - public Iteration Iteration { get; set; } + public Iteration InitialIteration { get; set; } /// /// Gets or sets a value indicating that another model can be selected for this TreeView or not @@ -154,9 +154,9 @@ public partial class ElementDefinitionTree /// protected override async Task OnAfterRenderAsync(bool firstRender) { - if (this.ViewModel.Iteration != this.Iteration) + if (this.ViewModel.Iteration != this.InitialIteration) { - this.Iteration = this.ViewModel.Iteration; + this.InitialIteration = this.ViewModel.Iteration; } } @@ -168,7 +168,7 @@ protected override void OnParametersSet() { base.OnParametersSet(); - this.ViewModel.Iteration = this.Iteration; + this.ViewModel.Iteration ??= this.InitialIteration; } /// diff --git a/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor b/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor index e42d29d9..ad61947a 100644 --- a/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor +++ b/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor @@ -32,7 +32,7 @@

Source Model

Target Model /// Add a new based on an existing ///
- /// The - Task CopyAndAddNewElement(ElementBase elementBase); + /// The to copy the node to + /// The to copy + Task CopyAndAddNewElement(ElementDefinitionTree elementDefinitionTree, ElementBase elementBase); /// /// Add a new based on an existing diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs index 08f58b4f..9d05f059 100644 --- a/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs @@ -36,6 +36,7 @@ namespace COMETwebapp.ViewModels.Components.MultiModelEditor using COMET.Web.Common.ViewModels.Components.Applications; using COMETwebapp.Components.ModelEditor; + using COMETwebapp.Components.MultiModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; using COMETwebapp.ViewModels.Components.SystemRepresentation; @@ -180,12 +181,13 @@ public void OpenAddParameterPopup() /// /// Add a new based on an existing /// - /// The - public async Task CopyAndAddNewElement(ElementBase elementBase) + /// The to copy the node to + /// The to copy + public async Task CopyAndAddNewElement(ElementDefinitionTree elementDefinitionTree, ElementBase elementBase) { this.IsLoading = true; - if (elementBase.GetContainerOfType() == this.CurrentThing) + if (elementBase.GetContainerOfType() == elementDefinitionTree.ViewModel.Iteration) { var copyCreator = new CopyElementDefinitionCreator(this.sessionService.Session); @@ -209,7 +211,7 @@ public async Task CopyAndAddNewElement(ElementBase elementBase) try { - await copyCreator.Copy((ElementDefinition)elementBase, this.CurrentThing); + await copyCreator.Copy((ElementDefinition)elementBase, elementDefinitionTree.ViewModel.Iteration); } catch (Exception exception) { @@ -230,7 +232,7 @@ public async Task CopyAndAddNewElement(ElementBase elementBase) /// The where to add the new to public async Task AddNewElementUsage(ElementBase fromElementBase, ElementBase toElementBase) { - if (fromElementBase.GetContainerOfType() == this.CurrentThing && toElementBase.GetContainerOfType() == this.CurrentThing) + if (fromElementBase.GetContainerOfType() == toElementBase.GetContainerOfType()) { this.IsLoading = true; @@ -238,7 +240,7 @@ public async Task AddNewElementUsage(ElementBase fromElementBase, ElementBase to try { - await thingCreator.CreateElementUsage((ElementDefinition)toElementBase, (ElementDefinition)fromElementBase, this.sessionService.Session.OpenIterations.First(x => x.Key == this.CurrentThing).Value.Item1, this.sessionService.Session); + await thingCreator.CreateElementUsage((ElementDefinition)toElementBase, (ElementDefinition)fromElementBase, this.sessionService.Session.OpenIterations.First(x => x.Key == toElementBase.GetContainerOfType()).Value.Item1, this.sessionService.Session); } catch (Exception exception) {