From f60da23c693503e39917ef0f7358e0b296989520 Mon Sep 17 00:00:00 2001 From: Daniel von Atzigen Date: Thu, 18 Jul 2024 15:55:23 +0200 Subject: [PATCH] Ignore asset selections when polygon is being drawn --- .../src/lib/components/map-controls/draw-controls.ts | 4 ++++ libs/asset-viewer/src/lib/components/map/map.component.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/asset-viewer/src/lib/components/map-controls/draw-controls.ts b/libs/asset-viewer/src/lib/components/map-controls/draw-controls.ts index 08a204fb..b2feca2c 100644 --- a/libs/asset-viewer/src/lib/components/map-controls/draw-controls.ts +++ b/libs/asset-viewer/src/lib/components/map-controls/draw-controls.ts @@ -91,6 +91,10 @@ export class DrawControl extends Control { return this._isDrawing$.asObservable(); } + get isDrawing(): boolean { + return this._isDrawing$.value; + } + setPolygon(polygon: LV95[] | null) { this._isDrawing$.next(false); this._polygon$.next(polygon); diff --git a/libs/asset-viewer/src/lib/components/map/map.component.ts b/libs/asset-viewer/src/lib/components/map/map.component.ts index 906bb76b..ca3ace2c 100644 --- a/libs/asset-viewer/src/lib/components/map/map.component.ts +++ b/libs/asset-viewer/src/lib/components/map/map.component.ts @@ -15,7 +15,7 @@ import { import { AppState } from '@asset-sg/client-shared'; import { ORD } from '@asset-sg/core'; import { Store } from '@ngrx/store'; -import { asapScheduler, first, identity, skip, Subscription, switchMap } from 'rxjs'; +import { asapScheduler, filter, first, identity, skip, Subscription, switchMap } from 'rxjs'; import { AllStudyService } from '../../services/all-study.service'; import * as searchActions from '../../state/asset-search/asset-search.actions'; import { @@ -127,7 +127,9 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { this.controller.addControl(this.controls.zoom); this.controller.addControl(this.controls.draw); - this.subscription.add(this.controller.assetsClick$.subscribe(this.assetsClick)); + this.subscription.add( + this.controller.assetsClick$.pipe(filter(() => !this.controls.draw.isDrawing)).subscribe(this.assetsClick) + ); this.subscription.add(this.controller.assetsHover$.subscribe(this.assetsHover)); // Some bindings can be initialized only after the map has fully loaded,