diff --git a/COMET.Web.Common/Utilities/HaveObjectChangedTracking/HaveObjectChangedTracking.cs b/COMET.Web.Common/Utilities/HaveObjectChangedTracking/HaveObjectChangedTracking.cs
index 066f126a..7732d9f0 100644
--- a/COMET.Web.Common/Utilities/HaveObjectChangedTracking/HaveObjectChangedTracking.cs
+++ b/COMET.Web.Common/Utilities/HaveObjectChangedTracking/HaveObjectChangedTracking.cs
@@ -77,12 +77,27 @@ protected void ClearRecordedChanges()
this.AddedThings.Clear();
}
+ ///
+ /// The logic used to check if a change should be recorded an
+ ///
+ /// The
+ /// true if the change should be recorded, false otherwise
+ protected virtual bool ShouldRecordChange(ObjectChangedEvent objectChangedEvent)
+ {
+ return true;
+ }
+
///
/// Records an
///
/// The
- protected virtual void RecordChange(ObjectChangedEvent objectChangedEvent)
+ private void RecordChange(ObjectChangedEvent objectChangedEvent)
{
+ if (!this.ShouldRecordChange(objectChangedEvent))
+ {
+ return;
+ }
+
switch (objectChangedEvent.EventKind)
{
case EventKind.Added:
diff --git a/COMET.Web.Common/ViewModels/Components/SingleIterationApplicationBaseViewModel.cs b/COMET.Web.Common/ViewModels/Components/SingleIterationApplicationBaseViewModel.cs
index 38e784ce..f73afddf 100644
--- a/COMET.Web.Common/ViewModels/Components/SingleIterationApplicationBaseViewModel.cs
+++ b/COMET.Web.Common/ViewModels/Components/SingleIterationApplicationBaseViewModel.cs
@@ -107,20 +107,6 @@ public Iteration CurrentIteration
///
public bool HasSetInitialValuesOnce { get; set; }
- ///
- /// Records an
- ///
- /// The
- protected override void RecordChange(ObjectChangedEvent objectChangedEvent)
- {
- if (this.CurrentIteration == null || objectChangedEvent.ChangedThing.GetContainerOfType().Iid != this.CurrentIteration.Iid)
- {
- return;
- }
-
- base.RecordChange(objectChangedEvent);
- }
-
///
/// Handles the refresh of the current
///
@@ -147,5 +133,20 @@ protected virtual async Task OnIterationChanged()
this.CurrentDomain = this.CurrentIteration == null ? null : this.SessionService.GetDomainOfExpertise(this.CurrentIteration);
await Task.CompletedTask;
}
+
+ ///
+ /// The logic used to check if a change should be recorded an
+ ///
+ /// The
+ /// true if the change should be recorded, false otherwise
+ protected override bool ShouldRecordChange(ObjectChangedEvent objectChangedEvent)
+ {
+ if (this.CurrentIteration == null || objectChangedEvent.ChangedThing.GetContainerOfType().Iid != this.CurrentIteration.Iid)
+ {
+ return false;
+ }
+
+ return true;
+ }
}
}
diff --git a/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs b/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs
index 6d8f9d29..ee2fe423 100644
--- a/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs
+++ b/COMETwebapp/ViewModels/Components/ParameterEditor/ParameterEditorBodyViewModel.cs
@@ -24,9 +24,6 @@
namespace COMETwebapp.ViewModels.Components.ParameterEditor
{
- using System.Reactive.Linq;
-
- using CDP4Common.CommonData;
using CDP4Common.EngineeringModelData;
using CDP4Common.SiteDirectoryData;
@@ -47,26 +44,21 @@ namespace COMETwebapp.ViewModels.Components.ParameterEditor
///
public class ParameterEditorBodyViewModel : SingleIterationApplicationBaseViewModel, IParameterEditorBodyViewModel
{
- ///
- /// A collection of added s
- ///
- private readonly List addedThings = new();
-
- ///
- /// A collection of deleted s
- ///
- private readonly List deletedThings = new();
-
///
/// Backing field for the
///
private bool isOwnedParameters;
///
- /// A collection of updated s
+ /// A collection of used to create subscriptions
///
- private readonly List updatedThings = new();
-
+ private static readonly IEnumerable ObjectChangedTypesOfInterest = new List
+ {
+ typeof(ElementBase),
+ typeof(ParameterOrOverrideBase),
+ typeof(ParameterValueSetBase),
+ };
+
///
/// Creates a new instance of
///
@@ -84,14 +76,7 @@ public ParameterEditorBodyViewModel(ISessionService sessionService, ISubscriptio
x => x.ParameterTypeSelector.SelectedParameterType,
x => x.IsOwnedParameters).SubscribeAsync(_ => this.ApplyFilters()));
- var observables = new List>
- {
- CDPMessageBus.Current.Listen(typeof(ParameterValueSetBase)),
- CDPMessageBus.Current.Listen(typeof(ElementBase)),
- CDPMessageBus.Current.Listen(typeof(ParameterOrOverrideBase))
- };
-
- this.Disposables.Add(observables.Merge().Subscribe(this.RecordChange));
+ this.InitializeSubscriptions(ObjectChangedTypesOfInterest);
}
///
@@ -134,17 +119,17 @@ public bool IsOwnedParameters
/// A
protected override async Task OnSessionRefreshed()
{
- if (!this.addedThings.Any() && !this.deletedThings.Any() && !this.updatedThings.Any())
+ if (!this.AddedThings.Any() && !this.DeletedThings.Any() && !this.UpdatedThings.Any())
{
return;
}
this.IsLoading = true;
await Task.Delay(1);
- this.ParameterTableViewModel.RemoveRows(this.deletedThings.ToList());
- this.ParameterTableViewModel.UpdateRows(this.updatedThings.ToList());
- this.ParameterTableViewModel.AddRows(this.addedThings.ToList());
- this.ClearRecordedChange();
+ this.ParameterTableViewModel.RemoveRows(this.DeletedThings.ToList());
+ this.ParameterTableViewModel.UpdateRows(this.UpdatedThings.ToList());
+ this.ParameterTableViewModel.AddRows(this.AddedThings.ToList());
+ this.ClearRecordedChanges();
this.IsLoading = false;
}
@@ -185,43 +170,6 @@ protected override async Task OnIterationChanged()
await this.InitializeTable();
}
- ///
- /// Clears all recorded changed
- ///
- private void ClearRecordedChange()
- {
- this.deletedThings.Clear();
- this.updatedThings.Clear();
- this.addedThings.Clear();
- }
-
- ///
- /// Records an
- ///
- /// The
- protected override void RecordChange(ObjectChangedEvent objectChangedEvent)
- {
- if (this.CurrentIteration == null || objectChangedEvent.ChangedThing.GetContainerOfType().Iid != this.CurrentIteration.Iid)
- {
- return;
- }
-
- switch (objectChangedEvent.EventKind)
- {
- case EventKind.Added:
- this.addedThings.Add(objectChangedEvent.ChangedThing);
- break;
- case EventKind.Removed:
- this.deletedThings.Add(objectChangedEvent.ChangedThing);
- break;
- case EventKind.Updated:
- this.updatedThings.Add(objectChangedEvent.ChangedThing);
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(objectChangedEvent), "Unrecognised value EventKind value");
- }
- }
-
///
/// Initialize the
///
diff --git a/COMETwebapp/ViewModels/Components/UserManagement/UserManagementTableViewModel.cs b/COMETwebapp/ViewModels/Components/UserManagement/UserManagementTableViewModel.cs
index 0bbdf67e..f85b6250 100644
--- a/COMETwebapp/ViewModels/Components/UserManagement/UserManagementTableViewModel.cs
+++ b/COMETwebapp/ViewModels/Components/UserManagement/UserManagementTableViewModel.cs
@@ -111,25 +111,13 @@ protected override async Task OnSessionRefreshed()
}
///
- /// Records an
+ /// The logic used to check if a change should be recorded an
///
- /// The
- protected override void RecordChange(ObjectChangedEvent objectChangedEvent)
+ /// The
+ /// true if the change should be recorded, false otherwise
+ protected override bool ShouldRecordChange(ObjectChangedEvent objectChangedEvent)
{
- switch (objectChangedEvent.EventKind)
- {
- case EventKind.Added:
- this.AddedThings.Add(objectChangedEvent.ChangedThing);
- break;
- case EventKind.Removed:
- this.DeletedThings.Add(objectChangedEvent.ChangedThing);
- break;
- case EventKind.Updated:
- this.UpdatedThings.Add(objectChangedEvent.ChangedThing);
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(objectChangedEvent), "Unrecognised value EventKind value");
- }
+ return true;
}
///
diff --git a/COMETwebapp/wwwroot/Scripts/babylonInterop.js b/COMETwebapp/wwwroot/Scripts/babylonInterop.js
index 07ef7756..b11621d1 100644
--- a/COMETwebapp/wwwroot/Scripts/babylonInterop.js
+++ b/COMETwebapp/wwwroot/Scripts/babylonInterop.js
@@ -112,9 +112,9 @@ let HighLightLayer;
* Inits the babylon.js scene on the canvas, the asociated resources and starts the render loop.
* @param {HTMLCanvasElement} canvas - the canvas the scene it's attached to.
*/
-function InitCanvas(canvas,addAxes) {
+function InitCanvas(canvas, addAxes) {
- if (canvas == null || canvas == undefined) {
+ if (canvas == null) {
throw "The canvas can't be null or undefined";
}
@@ -136,7 +136,6 @@ function InitCanvas(canvas,addAxes) {
CreateSkybox(Scene, SkyboxSize);
PickingMaterial = SetUpPickingMaterial();
- DetailsPanel = document.getElementById("detailsPanel");
SceneSpecularColor = new BABYLON.Color3(1.0, 1.0, 1.0);
SceneEmissiveColor = new BABYLON.Color3(0.0, 0.0, 0.0);
diff --git a/COMETwebapp/wwwroot/Scripts/babylonSpecifics.js b/COMETwebapp/wwwroot/Scripts/babylonSpecifics.js
index 90abe567..ecb0e042 100644
--- a/COMETwebapp/wwwroot/Scripts/babylonSpecifics.js
+++ b/COMETwebapp/wwwroot/Scripts/babylonSpecifics.js
@@ -42,7 +42,8 @@ function CreateScene(engine, canvas) {
Camera.panningSensibility = CameraPanningSensibility;
Camera.wheelPrecision = CameraZoomSensibility;
- let light1 = new BABYLON.HemisphericLight("HemisphericLight", new BABYLON.Vector3(2, 1, 0), scene);
+ let light = new BABYLON.HemisphericLight("HemisphericLight", new BABYLON.Vector3(2, 1, 0));
+ scene.light = light;
return scene;
};
@@ -190,8 +191,8 @@ async function LoadPrimitive(primitive) {
const result = await BABYLON.SceneLoader.ImportMeshAsync(null, path, fileName, Scene);
let meshes = result.meshes;
- for (let i = 0; i < meshes.length; i++) {
- InitializePrimitiveData(meshes[i], primitive);
+ for (let mesh of meshes) {
+ InitializePrimitiveData(mesh, primitive);
}
}