From 9f19ac0b3871d16c97496bc6f165483e5ddc8293 Mon Sep 17 00:00:00 2001 From: Alexander van Delft Date: Mon, 13 Jan 2025 17:29:02 +0100 Subject: [PATCH] Implement Copy Settings --- .../Enumerations/BrowserSessionSettingKey.cs | 9 +- COMET.Web.Common/Utilities/CopyCreator.cs | 5 +- COMET.Web.Common/wwwroot/css/styles.css | 4 +- .../MultiModelEditor/CopySettings.razor | 31 +++++ .../MultiModelEditor/CopySettings.razor.cs | 61 ++++++++++ .../ElementDefinitionTree.razor | 4 +- .../MultiModelEditor/MultiModelEditor.razor | 27 ++++- .../MultiModelEditor.razor.cs | 1 + .../Extensions/ServiceCollectionExtensions.cs | 2 + .../CopySettings/CopySettingsViewModel.cs | 114 ++++++++++++++++++ .../CopySettings/ICopySettingsViewModel.cs | 67 ++++++++++ .../ElementDefinitionTreeViewModel.cs | 7 +- .../IElementDefinitionTreeViewModel.cs | 1 + .../IMultiModelEditorViewModel.cs | 16 +++ .../MultiModelEditorViewModel.cs | 57 ++++++++- COMETwebapp/appsettings.Development.json | 2 +- COMETwebapp/wwwroot/css/app.css | 9 ++ 17 files changed, 398 insertions(+), 19 deletions(-) create mode 100644 COMETwebapp/Components/MultiModelEditor/CopySettings.razor create mode 100644 COMETwebapp/Components/MultiModelEditor/CopySettings.razor.cs create mode 100644 COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/CopySettingsViewModel.cs create mode 100644 COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/ICopySettingsViewModel.cs diff --git a/COMET.Web.Common/Enumerations/BrowserSessionSettingKey.cs b/COMET.Web.Common/Enumerations/BrowserSessionSettingKey.cs index fb575ed6..1106c454 100644 --- a/COMET.Web.Common/Enumerations/BrowserSessionSettingKey.cs +++ b/COMET.Web.Common/Enumerations/BrowserSessionSettingKey.cs @@ -27,6 +27,8 @@ namespace COMET.Web.Common.Enumerations using CDP4Common.EngineeringModelData; using CDP4Common.SiteDirectoryData; + using CDP4Dal.Operations; + /// /// En enumeration of possible keys to be used to store and retrieve cached BrowserSessionSettings /// @@ -45,6 +47,11 @@ public enum BrowserSessionSettingKey /// /// Key to handle the last selected /// - LastUsedDomainOfExpertise + LastUsedDomainOfExpertise, + + /// + /// Key to handle the type of to use when copying data from one model to another + /// + CopyElementDefinitionOperationKind } } diff --git a/COMET.Web.Common/Utilities/CopyCreator.cs b/COMET.Web.Common/Utilities/CopyCreator.cs index 90733892..f79b8fee 100644 --- a/COMET.Web.Common/Utilities/CopyCreator.cs +++ b/COMET.Web.Common/Utilities/CopyCreator.cs @@ -61,7 +61,8 @@ public CopyCreator(ISession session) /// /// The to copy /// The target container - public async Task CopyAsync(ElementDefinition elementDefinition, Iteration targetIteration) + /// The that defines the kind of copy operation. + public async Task CopyAsync(ElementDefinition elementDefinition, Iteration targetIteration, OperationKind operationKind = OperationKind.CopyDefaultValuesChangeOwner) { // copy the payload to this iteration var copyOperationHelper = new CopyPermissionHelper(this.session, false); @@ -69,7 +70,7 @@ public async Task CopyAsync(ElementDefinition elementDefinition, Iteration targe if (copyPermissionResult.ErrorList.Any() || copyPermissionResult.CopyableThings.Any()) { - await this.WriteCopyOperationAsync(elementDefinition, targetIteration, OperationKind.CopyKeepValuesChangeOwner); + await this.WriteCopyOperationAsync(elementDefinition, targetIteration, operationKind); } } diff --git a/COMET.Web.Common/wwwroot/css/styles.css b/COMET.Web.Common/wwwroot/css/styles.css index 8986761a..5978b4e0 100644 --- a/COMET.Web.Common/wwwroot/css/styles.css +++ b/COMET.Web.Common/wwwroot/css/styles.css @@ -618,9 +618,9 @@ } .treeview-scrollarea { - height: calc(90vh - 185px); + height: calc(90vh - 220px); } .cardview-detailspanel-scrollarea { - height: calc(90vh - 145px); + height: calc(90vh - 165px); } diff --git a/COMETwebapp/Components/MultiModelEditor/CopySettings.razor b/COMETwebapp/Components/MultiModelEditor/CopySettings.razor new file mode 100644 index 00000000..d87f1f44 --- /dev/null +++ b/COMETwebapp/Components/MultiModelEditor/CopySettings.razor @@ -0,0 +1,31 @@ + +@inherits DisposableComponent +When a user drops an ElementDefinition on this Engineering Model, data from the original ElementDefinition is copied using the following settings: + + diff --git a/COMETwebapp/Components/MultiModelEditor/CopySettings.razor.cs b/COMETwebapp/Components/MultiModelEditor/CopySettings.razor.cs new file mode 100644 index 00000000..7d81d1d9 --- /dev/null +++ b/COMETwebapp/Components/MultiModelEditor/CopySettings.razor.cs @@ -0,0 +1,61 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2024 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua +// +// 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 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 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. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Components.MultiModelEditor +{ + using COMET.Web.Common.Components; + + using COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings; + + using Microsoft.AspNetCore.Components; + + /// + /// Partial class for the component + /// + public partial class CopySettings : DisposableComponent + { + /// + /// The for the component + /// + [Parameter] + public ICopySettingsViewModel ViewModel { get; set; } + + /// + /// Action to perform after settings are saved. + /// + [Parameter] + public EventCallback OnAfterSaveSettings { get; set; } + + /// + /// Save the settings + /// + /// an awaitable + private async Task SaveSettings() + { + await this.ViewModel.SaveSettings(); + await this.InvokeAsync(this.StateHasChanged); + await this.OnAfterSaveSettings.InvokeAsync(); + } + } +} diff --git a/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor b/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor index 584beed9..f736783b 100644 --- a/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor +++ b/COMETwebapp/Components/MultiModelEditor/ElementDefinitionTree.razor @@ -50,13 +50,13 @@ else

-
+ style="padding:2px;border:dotted 1px;border-radius: 5px;height:25px;@(this.AllowDrop ? "" : "visibility:hidden;")"> Drop here to create new element...
diff --git a/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor b/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor index c2625db6..7641dac1 100644 --- a/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor +++ b/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor @@ -25,6 +25,14 @@ @inherits SingleIterationApplicationBase; +
+ + + + + Selected copy mode: @this.ViewModel.CopySettingsViewModel.SelectedOperationKindDescription + +
@@ -34,13 +42,13 @@ ScrollableAreaCssClass="treeview-scrollarea" InitialIteration="@this.ViewModel.CurrentThing" SelectionChanged="model => + { + if (model != null) { - if (model != null) - { - this.TargetTree.ClearSelection(); - } - this.OnElementSelected(model); - }" + this.TargetTree.ClearSelection(); + } + this.OnElementSelected(model); + }" AllowDrag="true" AllowDrop="true" OnCalculateDropIsAllowed="@(async x => await this.SetDropIsAllowedAsync(x))" @@ -107,4 +115,11 @@ + + + + + + + diff --git a/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor.cs b/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor.cs index 6ae73077..d6deed44 100644 --- a/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor.cs +++ b/COMETwebapp/Components/MultiModelEditor/MultiModelEditor.razor.cs @@ -73,6 +73,7 @@ protected override void OnViewModelAssigned() this.Disposables.Add(this.WhenAnyValue(x => x.ViewModel.IsOnCreationMode).SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); this.Disposables.Add(this.WhenAnyValue(x => x.ViewModel.IsOnAddingParameterMode).SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); + this.Disposables.Add(this.WhenAnyValue(x => x.ViewModel.IsOnCopySettingsMode).SubscribeAsync(_ => this.InvokeAsync(this.StateHasChanged))); } /// diff --git a/COMETwebapp/Extensions/ServiceCollectionExtensions.cs b/COMETwebapp/Extensions/ServiceCollectionExtensions.cs index 99cc9f37..f3a52c4b 100644 --- a/COMETwebapp/Extensions/ServiceCollectionExtensions.cs +++ b/COMETwebapp/Extensions/ServiceCollectionExtensions.cs @@ -62,6 +62,7 @@ namespace COMETwebapp.Extensions using COMETwebapp.ViewModels.Components.ReferenceData; using COMETwebapp.ViewModels.Pages; using COMETwebapp.ViewModels.Components.SiteDirectory; + using COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings; /// /// Extension class for the @@ -107,6 +108,7 @@ public static void RegisterViewModels(this IServiceCollection serviceCollection) serviceCollection.AddTransient(); serviceCollection.AddTransient(); serviceCollection.AddTransient(); + serviceCollection.AddTransient(); serviceCollection.AddTransient(); serviceCollection.AddTransient(); serviceCollection.AddTransient(); diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/CopySettingsViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/CopySettingsViewModel.cs new file mode 100644 index 00000000..ac094870 --- /dev/null +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/CopySettingsViewModel.cs @@ -0,0 +1,114 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2024 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua +// +// 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 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 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. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings +{ + using CDP4Dal.Operations; + + using COMET.Web.Common.Enumerations; + using COMET.Web.Common.Model; + using COMET.Web.Common.Services.Cache; + using COMET.Web.Common.Utilities.DisposableObject; + + using Microsoft.AspNetCore.Components; + + /// + /// View model for the component + /// + public class CopySettingsViewModel : DisposableObject, ICopySettingsViewModel + { + /// + /// Holds a reference to the Injected + /// + private readonly ICacheService cacheService; + + /// + /// Gets a collection of instance that can be selected as Copy Operation + /// + public CopyOperationKinds AvailableOperationKinds { get; } = new(); + + /// + /// Gets or sets the selected + /// + public OperationKind SelectedOperationKind { get; set; } = OperationKind.Copy; + + /// + /// The selected copy 's descriptive text + /// + public string SelectedOperationKindDescription => this.AvailableOperationKinds.Single(x => x.Value == this.SelectedOperationKind).Key; + + /// + /// The callback executed when the method was executed + /// + public EventCallback OnSaveSettings { get; set; } + + /// + /// Create a new instance of the class + /// + /// The Injected + public CopySettingsViewModel(ICacheService cacheService) + { + this.cacheService = cacheService; + + if (this.cacheService.TryGetOrAddBrowserSessionSetting(BrowserSessionSettingKey.CopyElementDefinitionOperationKind, OperationKind.Copy, out var selectedOperationKind) && selectedOperationKind is OperationKind operationKind) + { + this.SelectedOperationKind = operationKind; + } + } + + /// + /// Initializes the current view model + /// + public void InitializeViewModel() + { + } + + /// + /// Saves the Settings + /// + /// An awaitable + public async Task SaveSettings() + { + this.cacheService.AddOrUpdateBrowserSessionSetting(BrowserSessionSettingKey.CopyElementDefinitionOperationKind, this.SelectedOperationKind); + await this.OnSaveSettings.InvokeAsync(); + } + } + + /// + /// Defines a collection of descriptive strings that belongs to an + /// + public class CopyOperationKinds : Dictionary + { + /// + /// Creates a new instance of the + /// + public CopyOperationKinds() + { + this.Add("Set Parameter values to default, keep original owner", OperationKind.Copy); + this.Add("Set Parameter values to default, change owner to active domain", OperationKind.CopyDefaultValuesChangeOwner); + this.Add("Keep parameter values, keep original owner", OperationKind.CopyKeepValues); + this.Add("Keep parameter values, change owner to active domain", OperationKind.CopyKeepValuesChangeOwner); + } + } +} diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/ICopySettingsViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/ICopySettingsViewModel.cs new file mode 100644 index 00000000..1bd7097a --- /dev/null +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/CopySettings/ICopySettingsViewModel.cs @@ -0,0 +1,67 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2024 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua +// +// 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 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 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. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings +{ + using CDP4Dal.Operations; + + using Microsoft.AspNetCore.Components; + + /// + /// Interface for the + /// + public interface ICopySettingsViewModel + { + /// + /// Gets a collection of instance that can be selected as Copy Operation + /// + CopyOperationKinds AvailableOperationKinds { get; } + + /// + /// Gets the selected + /// + OperationKind SelectedOperationKind { get; set; } + + /// + /// The callback executed when the method was executed + /// + EventCallback OnSaveSettings { get; set; } + + /// + /// The selected copy 's descriptive text + /// + string SelectedOperationKindDescription { get; } + + /// + /// Initializes the current view model + /// + void InitializeViewModel(); + + /// + /// Saves the Settings + /// + /// An awaitable + Task SaveSettings(); + } +} diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/ElementDefinitionTreeViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/ElementDefinitionTreeViewModel.cs index 2aaf4ce6..38e1bd27 100644 --- a/COMETwebapp/ViewModels/Components/MultiModelEditor/ElementDefinitionTreeViewModel.cs +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/ElementDefinitionTreeViewModel.cs @@ -38,10 +38,14 @@ namespace COMETwebapp.ViewModels.Components.MultiModelEditor using COMETwebapp.Components.MultiModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor; + using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; + using COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings; using COMETwebapp.ViewModels.Components.MultiModelEditor.Rows; using DynamicData; + using Microsoft.AspNetCore.Components; + using ReactiveUI; /// @@ -74,7 +78,8 @@ public class ElementDefinitionTreeViewModel : ApplicationBaseViewModel, IElement /// /// the /// The - public ElementDefinitionTreeViewModel(ISessionService sessionService, ICDPMessageBus messageBus) : base(sessionService, messageBus) + /// The Injected + public ElementDefinitionTreeViewModel(ISessionService sessionService, ICDPMessageBus messageBus, ICopySettingsViewModel copySettingsViewModel) : base(sessionService, messageBus) { this.sessionService = sessionService; this.RegisterViewModelWithReusableRows(this); diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/IElementDefinitionTreeViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/IElementDefinitionTreeViewModel.cs index 720aa34d..ba4798a3 100644 --- a/COMETwebapp/ViewModels/Components/MultiModelEditor/IElementDefinitionTreeViewModel.cs +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/IElementDefinitionTreeViewModel.cs @@ -31,6 +31,7 @@ namespace COMETwebapp.ViewModels.Components.MultiModelEditor using COMET.Web.Common.Model; using COMET.Web.Common.ViewModels.Components.Applications; + using COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings; using COMETwebapp.ViewModels.Components.MultiModelEditor.Rows; /// diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/IMultiModelEditorViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/IMultiModelEditorViewModel.cs index b795cbf9..a261f1ba 100644 --- a/COMETwebapp/ViewModels/Components/MultiModelEditor/IMultiModelEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/IMultiModelEditorViewModel.cs @@ -32,6 +32,7 @@ namespace COMETwebapp.ViewModels.Components.MultiModelEditor using COMETwebapp.Components.MultiModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; + using COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings; using COMETwebapp.ViewModels.Components.SystemRepresentation; /// @@ -74,11 +75,21 @@ public interface IMultiModelEditorViewModel : ISingleIterationApplicationBaseVie /// IAddParameterViewModel AddParameterViewModel { get; set; } + /// + /// Gets the + /// + ICopySettingsViewModel CopySettingsViewModel { get; set; } + /// /// Value indicating the user is currently adding a new to a /// bool IsOnAddingParameterMode { get; set; } + /// + /// Value indicating the user is currently setting the Copy settings that apply when a node is dropped + /// + bool IsOnCopySettingsMode { get; set; } + /// /// Opens the popup /// @@ -95,6 +106,11 @@ public interface IMultiModelEditorViewModel : ISingleIterationApplicationBaseVie /// void OpenAddParameterPopup(); + /// + /// Opens the popup + /// + void OpenCopySettingsPopup(); + /// /// Add a new based on an existing /// diff --git a/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs b/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs index fceec26f..bebe43a4 100644 --- a/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs +++ b/COMETwebapp/ViewModels/Components/MultiModelEditor/MultiModelEditorViewModel.cs @@ -30,7 +30,10 @@ namespace COMETwebapp.ViewModels.Components.MultiModelEditor using CDP4Dal; using CDP4Dal.Events; + using CDP4Dal.Operations; + using COMET.Web.Common.Enumerations; + using COMET.Web.Common.Services.Cache; using COMET.Web.Common.Services.SessionManagement; using COMET.Web.Common.Utilities; using COMET.Web.Common.ViewModels.Components.Applications; @@ -39,6 +42,7 @@ namespace COMETwebapp.ViewModels.Components.MultiModelEditor using COMETwebapp.Components.MultiModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor; using COMETwebapp.ViewModels.Components.ModelEditor.AddParameterViewModel; + using COMETwebapp.ViewModels.Components.MultiModelEditor.CopySettings; using COMETwebapp.ViewModels.Components.SystemRepresentation; using COMETwebapp.ViewModels.Components.SystemRepresentation.Rows; @@ -56,6 +60,11 @@ public class MultiModelEditorViewModel : SingleIterationApplicationBaseViewModel /// private readonly ISessionService sessionService; + /// + /// The + /// + private readonly ICacheService cacheService; + /// /// Backing field for /// @@ -66,14 +75,21 @@ public class MultiModelEditorViewModel : SingleIterationApplicationBaseViewModel /// private bool isOnCreationMode; + /// + /// Backing field for + /// + private bool isOnCopySettingsMode; + /// /// Creates a new instance of /// /// the /// The - public MultiModelEditorViewModel(ISessionService sessionService, ICDPMessageBus messageBus) : base(sessionService, messageBus) + /// The + public MultiModelEditorViewModel(ISessionService sessionService, ICDPMessageBus messageBus, ICacheService cacheService) : base(sessionService, messageBus) { this.sessionService = sessionService; + this.cacheService = cacheService; var eventCallbackFactory = new EventCallbackFactory(); this.ElementDefinitionCreationViewModel = new ElementDefinitionCreationViewModel(sessionService, messageBus) @@ -86,6 +102,11 @@ public MultiModelEditorViewModel(ISessionService sessionService, ICDPMessageBus OnParameterAdded = eventCallbackFactory.Create(this, () => this.IsOnAddingParameterMode = false) }; + this.CopySettingsViewModel = new CopySettingsViewModel(cacheService) + { + OnSaveSettings = eventCallbackFactory.Create(this, () => this.IsOnCopySettingsMode = false) + }; + this.InitializeSubscriptions([typeof(ElementBase)]); this.TargetIteration = this.CurrentThing; @@ -111,6 +132,11 @@ public MultiModelEditorViewModel(ISessionService sessionService, ICDPMessageBus /// public IAddParameterViewModel AddParameterViewModel { get; set; } + /// + /// Gets or sets the + /// + public ICopySettingsViewModel CopySettingsViewModel { get; set; } + /// /// Gets target /// @@ -121,6 +147,24 @@ public MultiModelEditorViewModel(ISessionService sessionService, ICDPMessageBus /// public Iteration SourceIteration { get; set; } + /// + /// Value indicating the user is currently setting the Copy settings that apply when a node is dropped + /// + public bool IsOnCopySettingsMode + { + get => this.isOnCopySettingsMode; + set => this.RaiseAndSetIfChanged(ref this.isOnCopySettingsMode, value); + } + + /// + /// Opens the popup + /// + public void OpenCopySettingsPopup() + { + this.CopySettingsViewModel.InitializeViewModel(); + this.IsOnCopySettingsMode = true; + } + /// /// Value indicating the user is currently creating a new /// @@ -164,6 +208,7 @@ public void SelectElement(ElementBase selectedElementBase) /// public void OpenCreateElementDefinitionCreationPopup() { + this.ElementDefinitionCreationViewModel.InitializeViewModel(this.SelectedElementDefinition.GetContainerOfType()); this.ElementDefinitionCreationViewModel.ElementDefinition = new ElementDefinition(); this.ElementDefinitionCreationViewModel.SelectedCategories = new List(); this.IsOnCreationMode = true; @@ -210,7 +255,10 @@ private async Task CopyAndAddNewElementImplAsync(ElementDefinitionTree elementDe else { var copyCreator = new CopyCreator(this.sessionService.Session); - await copyCreator.CopyAsync((ElementDefinition)elementBase, elementDefinitionTree.ViewModel.Iteration); + + this.cacheService.TryGetOrAddBrowserSessionSetting(BrowserSessionSettingKey.CopyElementDefinitionOperationKind, OperationKind.Copy, out var selectedOperationKind); + + await copyCreator.CopyAsync((ElementDefinition)elementBase, elementDefinitionTree.ViewModel.Iteration, selectedOperationKind is OperationKind operationKind ? operationKind : OperationKind.Copy); } } finally @@ -270,9 +318,10 @@ public async Task AddingElementDefinitionAsync() this.ElementDefinitionCreationViewModel.ElementDefinition.Category = this.ElementDefinitionCreationViewModel.SelectedCategories.ToList(); } - this.ElementDefinitionCreationViewModel.ElementDefinition.Container = this.CurrentThing; + var iteration = this.SelectedElementDefinition.GetContainerOfType(); + this.ElementDefinitionCreationViewModel.ElementDefinition.Container = iteration; thingsToCreate.Add(this.ElementDefinitionCreationViewModel.ElementDefinition); - var clonedIteration = this.CurrentThing.Clone(false); + var clonedIteration = iteration.Clone(false); if (this.ElementDefinitionCreationViewModel.IsTopElement) { diff --git a/COMETwebapp/appsettings.Development.json b/COMETwebapp/appsettings.Development.json index 7db92f2e..a7200e21 100644 --- a/COMETwebapp/appsettings.Development.json +++ b/COMETwebapp/appsettings.Development.json @@ -1,6 +1,6 @@ { "ServerConfiguration": { - "ServerAddress": "" + "ServerAddress": "http://localhost:5000/" }, "DetailedErrors": true } diff --git a/COMETwebapp/wwwroot/css/app.css b/COMETwebapp/wwwroot/css/app.css index e8d71525..d4b25d4a 100644 --- a/COMETwebapp/wwwroot/css/app.css +++ b/COMETwebapp/wwwroot/css/app.css @@ -316,4 +316,13 @@ sub { .search-mark { background-color: yellow !important; + color:black !important; +} + +.drop-area-background-color { + background-color: cadetblue !important; +} + +.drop-area-color { + color: cadetblue !important; }