Hide 'add new element' when an element is selected

This commit is contained in:
Pieter Vander Vennet 2024-07-19 11:26:12 +02:00
parent 6f59b09c11
commit 768e709312
2 changed files with 14 additions and 3 deletions

View file

@ -18,6 +18,7 @@ export class LastClickFeatureSource implements FeatureSource {
private readonly hasNoteLayer: boolean private readonly hasNoteLayer: boolean
public static readonly newPointElementId = "new_point_dialog" public static readonly newPointElementId = "new_point_dialog"
public readonly features: Store<Feature[]> public readonly features: Store<Feature[]>
private readonly _features: UIEventSource<Feature[]>
private _usermode: UIEventSource<string> private _usermode: UIEventSource<string>
private _enabledAddMorePoints: UIEventSource<boolean> private _enabledAddMorePoints: UIEventSource<boolean>
constructor( constructor(
@ -53,9 +54,13 @@ export class LastClickFeatureSource implements FeatureSource {
) )
) )
this.features = clickSource.mapD(({ lon, lat, mode }) => [ this._features = new UIEventSource<Feature[]>([])
this.createFeature(lon, lat, mode), this.features = this._features
]) clickSource.addCallbackAndRunD(({ lon, lat, mode }) => {
this._features.setData([
this.createFeature(lon, lat, mode)
])
})
} }
public createFeature( public createFeature(
@ -85,4 +90,8 @@ export class LastClickFeatureSource implements FeatureSource {
}, },
} }
} }
clear() {
this._features.setData([])
}
} }

View file

@ -853,6 +853,8 @@ export default class ThemeViewState implements SpecialVisualizationState {
this.selectedElement.addCallback((selected) => { this.selectedElement.addCallback((selected) => {
if (selected === undefined) { if (selected === undefined) {
this.focusOnMap() this.focusOnMap()
}else{
this.lastClickObject.clear()
} }
}) })
this.guistate.allToggles.forEach((toggle) => { this.guistate.allToggles.forEach((toggle) => {