From 768e7093128e4d1e1975662b9219ea911b75e862 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 19 Jul 2024 11:26:12 +0200 Subject: [PATCH] Hide 'add new element' when an element is selected --- .../Sources/LastClickFeatureSource.ts | 15 ++++++++++++--- src/Models/ThemeViewState.ts | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Logic/FeatureSource/Sources/LastClickFeatureSource.ts b/src/Logic/FeatureSource/Sources/LastClickFeatureSource.ts index 3d3871d16..71d90914f 100644 --- a/src/Logic/FeatureSource/Sources/LastClickFeatureSource.ts +++ b/src/Logic/FeatureSource/Sources/LastClickFeatureSource.ts @@ -18,6 +18,7 @@ export class LastClickFeatureSource implements FeatureSource { private readonly hasNoteLayer: boolean public static readonly newPointElementId = "new_point_dialog" public readonly features: Store + private readonly _features: UIEventSource private _usermode: UIEventSource private _enabledAddMorePoints: UIEventSource constructor( @@ -53,9 +54,13 @@ export class LastClickFeatureSource implements FeatureSource { ) ) - this.features = clickSource.mapD(({ lon, lat, mode }) => [ - this.createFeature(lon, lat, mode), - ]) + this._features = new UIEventSource([]) + this.features = this._features + clickSource.addCallbackAndRunD(({ lon, lat, mode }) => { + this._features.setData([ + this.createFeature(lon, lat, mode) + ]) + }) } public createFeature( @@ -85,4 +90,8 @@ export class LastClickFeatureSource implements FeatureSource { }, } } + + clear() { + this._features.setData([]) + } } diff --git a/src/Models/ThemeViewState.ts b/src/Models/ThemeViewState.ts index 26b608e76..480bdbda7 100644 --- a/src/Models/ThemeViewState.ts +++ b/src/Models/ThemeViewState.ts @@ -853,6 +853,8 @@ export default class ThemeViewState implements SpecialVisualizationState { this.selectedElement.addCallback((selected) => { if (selected === undefined) { this.focusOnMap() + }else{ + this.lastClickObject.clear() } }) this.guistate.allToggles.forEach((toggle) => {