Skip to content

Commit 0731827

Browse files
committed
Use available copy layers config
1 parent 5964a82 commit 0731827

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

projects/core/src/lib/components/edit/edit/edit.component.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1616
import { switchMap, withLatestFrom } from 'rxjs/operators';
1717
import { hideFeatureInfoDialog } from '../../feature-info/state/feature-info.actions';
1818
import { ApplicationLayerService } from '../../../map/services/application-layer.service';
19-
import { AppLayerModel, AttributeType, AuthenticatedUserService, GeometryType } from '@tailormap-viewer/api';
19+
import {
20+
AppLayerModel, AttributeType, AuthenticatedUserService, BaseComponentTypeEnum, EditConfigModel, GeometryType,
21+
} from '@tailormap-viewer/api';
2022
import { activateTool } from '../../toolbar/state/toolbar.actions';
2123
import { ToolbarComponentEnum } from '../../toolbar/models/toolbar-component.enum';
2224
import { DrawingType, MapService, ScaleHelper } from '@tailormap-viewer/map';
25+
import { ComponentConfigHelper } from '../../../shared';
2326

2427
@Component({
2528
selector: 'tm-edit',
@@ -53,6 +56,8 @@ export class EditComponent implements OnInit {
5356
public tooltip = this.defaultTooltip;
5457
public disabled = false;
5558

59+
private selectedCopyLayerIds: string[] = [];
60+
5661
public ngOnInit(): void {
5762
this.store$.select(selectSelectedEditLayer)
5863
.pipe(takeUntilDestroyed(this.destroyRef))
@@ -86,14 +91,23 @@ export class EditComponent implements OnInit {
8691
}
8792
});
8893

94+
ComponentConfigHelper.useInitialConfigForComponent<EditConfigModel>(
95+
this.store$,
96+
BaseComponentTypeEnum.EDIT,
97+
config => {
98+
this.selectedCopyLayerIds = config.copyLayerIds || [];
99+
},
100+
);
101+
89102
combineLatest([ this.store$.select(selectSelectedEditLayer),
90103
this.store$.select(selectOrderedVisibleLayersWithServices),
91104
this.mapService.getMapViewDetails$() ]).pipe(
92105
takeUntilDestroyed(this.destroyRef),
93106
).subscribe(([ selectedEditLayerId, visibleLayers, mapViewDetails ]) => {
94107
const layers = selectedEditLayerId == null ? [] : visibleLayers.filter(layer =>
95108
layer.id !== selectedEditLayerId
96-
&& ScaleHelper.isInScale(mapViewDetails.scale, layer.minScale, layer.maxScale));
109+
&& ScaleHelper.isInScale(mapViewDetails.scale, layer.minScale, layer.maxScale)
110+
&& this.selectedCopyLayerIds.length == 0 || this.selectedCopyLayerIds.includes(layer.id));
97111
this.layersToCreateNewFeaturesFrom.set(layers);
98112
});
99113
}

0 commit comments

Comments
 (0)