Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
GBIM-317: Hide geometry after closing form. (#3201)
Browse files Browse the repository at this point in the history
* GBIM-317: Hide geometry after closing form.

* Fix lint
  • Loading branch information
geertplaisier authored Apr 14, 2022
1 parent d8269ef commit 81076c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 81076c3

Please sign in to comment.