From 81076c3129eeff8db5fda1445a54d683c8423398 Mon Sep 17 00:00:00 2001 From: Geert Plaisier Date: Thu, 14 Apr 2022 14:23:43 +0200 Subject: [PATCH] GBIM-317: Hide geometry after closing form. (#3201) * GBIM-317: Hide geometry after closing form. * Fix lint --- .../src/lib/feature-form/state/form.state-helpers.ts | 7 ++++++- .../lib/workflow/workflows/StandardFormWorkflow.ts | 11 ++++------- .../core/src/lib/workflow/workflows/Workflow.ts | 8 +++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tailormap-components/projects/core/src/lib/feature-form/state/form.state-helpers.ts b/tailormap-components/projects/core/src/lib/feature-form/state/form.state-helpers.ts index 98e2370f1d..04fe9d2a73 100644 --- a/tailormap-components/projects/core/src/lib/feature-form/state/form.state-helpers.ts +++ b/tailormap-components/projects/core/src/lib/feature-form/state/form.state-helpers.ts @@ -1,4 +1,4 @@ -import { selectFeatureFormEnabled } from './form.selectors'; +import { selectFeatureFormEnabled, selectFormEditing } from './form.selectors'; import { pipe } from 'rxjs'; import { select } from '@ngrx/store'; import { filter } from 'rxjs/operators'; @@ -10,6 +10,11 @@ export const selectFormClosed = pipe( filter(open => !open), ); +export const selectFormEditingDone = pipe( + select(selectFormEditing), + filter(editing => !editing), +); + export const removeFeature = (features: Feature[], removed: Feature): Feature[] => { const idx = features.findIndex(feature => feature.fid === removed.fid); const updatedFeatures = idx !== -1 diff --git a/tailormap-components/projects/core/src/lib/workflow/workflows/StandardFormWorkflow.ts b/tailormap-components/projects/core/src/lib/workflow/workflows/StandardFormWorkflow.ts index 6768ac5cd5..d9e3ed936a 100644 --- a/tailormap-components/projects/core/src/lib/workflow/workflows/StandardFormWorkflow.ts +++ b/tailormap-components/projects/core/src/lib/workflow/workflows/StandardFormWorkflow.ts @@ -3,10 +3,10 @@ import * as wellknown from 'wellknown'; import { Feature } from '../../shared/generated'; import { MapClickedEvent } from '../../shared/models/event-models'; import { OLFeature, VectorLayer } from '../../../../../bridge/typings'; -import { concatMap, filter, take, takeUntil } from 'rxjs/operators'; +import { concatMap, take, takeUntil } from 'rxjs/operators'; import { WorkflowHelper } from './workflow.helper'; import * as FormActions from '../../feature-form/state/form.actions'; -import { selectFormClosed } from '../../feature-form/state/form.state-helpers'; +import { selectFormClosed, selectFormEditingDone } from '../../feature-form/state/form.state-helpers'; import { selectFormConfigForFeatureTypeName } from '../../application/state/application.selectors'; import { selectFeatureType, selectGeometryType, selectWorkflowConfig } from '../state/workflow.selectors'; import { combineLatest, of } from 'rxjs'; @@ -47,10 +47,7 @@ export class StandardFormWorkflow extends Workflow { }); this.store$.select(selectCurrentFeature) - .pipe( - takeUntil(this.destroyed), - filter(feature => !!feature), - ) + .pipe(takeUntil(this.destroyed)) .subscribe(feature => { this.zoomToFeature(feature); }); @@ -98,7 +95,7 @@ export class StandardFormWorkflow extends Workflow { public openDialog(formFeatures?: Feature[], editMode: boolean = false, createdFeature?: boolean): void { this.store$.dispatch(FormActions.setOpenFeatureForm({features: formFeatures, editMode})); - this.store$.pipe(selectFormClosed) + this.store$.pipe(editMode ? selectFormEditingDone : selectFormClosed) .pipe(take(1)) .subscribe(() => { this.afterEditing(createdFeature); diff --git a/tailormap-components/projects/core/src/lib/workflow/workflows/Workflow.ts b/tailormap-components/projects/core/src/lib/workflow/workflows/Workflow.ts index ece42ef1bd..d5696692f9 100644 --- a/tailormap-components/projects/core/src/lib/workflow/workflows/Workflow.ts +++ b/tailormap-components/projects/core/src/lib/workflow/workflows/Workflow.ts @@ -86,10 +86,12 @@ export abstract class Workflow { this.close$.next(true); } - public zoomToFeature(feature: Feature) { - const geom = this.featureInitializerService.retrieveGeometry(feature); + public zoomToFeature(feature?: Feature) { + const geom = feature + ? this.featureInitializerService.retrieveGeometry(feature) + : null; + this.highlightLayer.removeAllFeatures(); if (geom) { - this.highlightLayer.removeAllFeatures(); this.highlightLayer.readGeoJSON(geom); } }