Skip to content

Commit cf1faa9

Browse files
committed
Show active state for new geometry/copy features, show number of copied features in badge, show new/edit title in edit dialog, small fixes
1 parent 9ad22ea commit cf1faa9

File tree

14 files changed

+57
-48
lines changed

14 files changed

+57
-48
lines changed

projects/core/assets/locale/messages.core.de.xlf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@
427427
<target>Löschen des Features fehlgeschlagen</target>
428428
</trans-unit>
429429
<trans-unit id="core.edit.edit" datatype="html">
430-
<source>Edit</source>
431-
<target>Bearbeiten</target>
432-
</trans-unit>
433-
<trans-unit id="core.edit.edit-feature-tooltip" datatype="html">
434430
<source>Edit feature</source>
435431
<target>Objekt bearbeiten</target>
436432
</trans-unit>

projects/core/assets/locale/messages.core.en.xlf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@
321321
<source>Delete feature failed</source>
322322
</trans-unit>
323323
<trans-unit id="core.edit.edit" datatype="html">
324-
<source>Edit</source>
325-
</trans-unit>
326-
<trans-unit id="core.edit.edit-feature-tooltip" datatype="html">
327324
<source>Edit feature</source>
328325
</trans-unit>
329326
<trans-unit id="core.edit.error-getting-features" datatype="html">

projects/core/assets/locale/messages.core.nl.xlf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@
427427
<target>Object verwijderen mislukt</target>
428428
</trans-unit>
429429
<trans-unit id="core.edit.edit" datatype="html">
430-
<source>Edit</source>
431-
<target>Bewerken</target>
432-
</trans-unit>
433-
<trans-unit id="core.edit.edit-feature-tooltip" datatype="html">
434430
<source>Edit feature</source>
435431
<target>Object bewerken</target>
436432
</trans-unit>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ApplicationMapModule } from '../../map/application-map.module';
1313
import { EditSelectFeatureComponent } from './edit-select-feature/edit-select-feature.component';
1414
import { SelectFieldComponent } from './fields/select-field/select-field.component';
1515
import { CoreSharedModule } from '../../shared';
16-
16+
import { MatBadge } from '@angular/material/badge';
1717

1818
@NgModule({
1919
declarations: [
@@ -30,6 +30,7 @@ import { CoreSharedModule } from '../../shared';
3030
EffectsModule.forFeature([EditEffects]),
3131
ApplicationMapModule,
3232
CoreSharedModule,
33+
MatBadge,
3334
],
3435
exports: [
3536
EditComponent,

projects/core/src/lib/components/edit/edit-dialog/edit-dialog.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
[allowCollapse]="true"
88
[collapsed]="dialogCollapsed$ | async"
99
(expandCollapseDialog)="expandCollapseDialog()"
10-
dialogTitle="Edit"
11-
i18n-dialogTitle="@@core.edit.edit">
10+
[dialogTitle]="dialogTitle$ | async">
1211
@let currentFeature = currentFeature$ | async;
1312
@let layerDetails = layerDetails$ | async;
1413
@if (currentFeature && layerDetails) {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, inje
22
import { Store } from '@ngrx/store';
33
import { ConfirmDialogService, CssHelper } from '@tailormap-viewer/shared';
44
import {
5-
selectEditCreateNewFeatureActive, selectEditDialogCollapsed, selectEditDialogVisible, selectEditFeatures, selectEditMapCoordinates,
5+
selectEditCreateNewOrCopyFeatureActive, selectEditDialogCollapsed, selectEditDialogVisible, selectEditFeatures, selectEditMapCoordinates,
66
selectEditOpenedFromFeatureInfo, selectLoadingEditFeatures, selectSelectedEditFeature,
77
} from '../state/edit.selectors';
88
import { combineLatest, concatMap, filter, map, of, switchMap, take } from 'rxjs';
@@ -44,6 +44,7 @@ export class EditDialogComponent {
4444
public dialogCollapsed$;
4545
public isCreateFeature$;
4646
public currentFeature$;
47+
public dialogTitle$;
4748
public layerDetails$;
4849
public selectableFeature$;
4950

@@ -70,7 +71,11 @@ export class EditDialogComponent {
7071
this.loadingEditFeatureInfo$ = this.store$.select(selectLoadingEditFeatures);
7172
this.editCoordinates$ = this.store$.select(selectEditMapCoordinates);
7273
this.currentFeature$ = this.store$.select(selectSelectedEditFeature);
73-
this.isCreateFeature$ = this.store$.select(selectEditCreateNewFeatureActive);
74+
this.dialogTitle$ = this.currentFeature$.pipe(
75+
map(feature => feature?.feature.__fid !== 'new'
76+
? $localize `:@@core.edit.edit:Edit feature`
77+
: $localize `:@@core.edit.add-new-feature:Add new feature`));
78+
this.isCreateFeature$ = this.store$.select(selectEditCreateNewOrCopyFeatureActive);
7479
this.selectableFeature$ = combineLatest([
7580
this.store$.select(selectEditFeatures),
7681
this.store$.select(selectSelectedEditFeature),

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
}
99

1010
.edit-container--is-active {
11-
padding: 5px 6px 5px 0;
12-
width: 300px;
11+
padding: 5px 11px 5px 0;
12+
width: 305px;
1313
height: 70px;
1414
max-width: var(--max-control-width);
1515
}

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
<mat-icon svgIcon="edit"></mat-icon>
1212
</button>
1313
@if (active$ | async) {
14-
<div class="edit-wrapper"
15-
>
14+
<div class="edit-wrapper">
1615
<ng-container>
1716
@if (editableLayers.length > 0) {
1817
<mat-form-field appearance="outline" color="primary">
@@ -35,7 +34,8 @@
3534
tmTooltip="Add new feature"
3635
i18n-tmTooltip="@@core.edit.add-new-feature"
3736
class="map-control-button map-control-button--add-feature"
38-
mat-flat-button>
37+
mat-flat-button
38+
[class.toggle-button--active]="createNewFeatureActive$ | async">
3939
<mat-icon svgIcon="new_object"></mat-icon>
4040
</button>
4141
<mat-menu #geometryTypeMenu="matMenu" xPosition="after" yPosition="below">
@@ -57,16 +57,21 @@
5757
i18n-tmTooltip="@@core.edit.add-new-feature"
5858
class="map-control-button map-control-button--add-feature"
5959
(click)="createFeatureIfSingleGeometryType()"
60-
mat-flat-button>
60+
mat-flat-button
61+
[class.toggle-button--active]="createNewFeatureActive$ | async">
6162
<mat-icon svgIcon="new_object"></mat-icon>
6263
</button>
6364
}
6465
@if (layersToCreateNewFeaturesFrom().length > 0) {
6566
<button [matMenuTriggerFor]="layerToCreateNewFeaturesFromMenu"
6667
tmTooltip="Copy from other layer"
67-
class="map-control-button map-control-button--copy-feature"
68-
[class.active]="layer.value !== null"
69-
mat-flat-button>
68+
class="map-control-button"
69+
mat-flat-button
70+
[matBadge]="copiedFeaturesCount$ | async"
71+
[matBadgeHidden]="(copyActive$ | async) === false"
72+
matBadgeSize="small"
73+
matBadgeColor="primary"
74+
[class.toggle-button--active]="copyActive$ | async">
7075
<mat-icon svgIcon="split"></mat-icon>
7176
</button>
7277
<mat-menu #layerToCreateNewFeaturesFromMenu="matMenu" xPosition="after" yPosition="below">

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { ChangeDetectionStrategy, Component, DestroyRef, OnInit, inject, signal } from '@angular/core';
2-
import { selectEditActive, selectSelectedEditLayer } from '../state/edit.selectors';
2+
import {
3+
selectCopiedFeatures,
4+
selectEditActive, selectEditCopyOtherLayerFeaturesActive, selectEditCreateNewFeatureActive, selectEditCreateNewOrCopyFeatureActive,
5+
selectSelectedEditLayer,
6+
} from '../state/edit.selectors';
37
import { Store } from '@ngrx/store';
4-
import { combineLatest, of, take } from 'rxjs';
8+
import { combineLatest, map, of, take } from 'rxjs';
59
import {
610
setEditActive, setEditCopyOtherLayerFeaturesActive, setEditCreateNewFeatureActive, setSelectedEditLayer,
711
} from '../state/edit.actions';
@@ -31,13 +35,16 @@ export class EditComponent implements OnInit {
3135
private mapService = inject(MapService);
3236

3337
public active$ = this.store$.select(selectEditActive);
38+
public createNewFeatureActive$ = this.store$.select(selectEditCreateNewFeatureActive);
39+
public copyActive$ = this.store$.select(selectEditCopyOtherLayerFeaturesActive);
40+
public copiedFeaturesCount$ = this.store$.select(selectCopiedFeatures).pipe(map(features => features.length));
3441
public editableLayers$ = this.store$.select(selectEditableLayers);
3542
public layer = new FormControl();
3643
public editGeometryType: GeometryType | null = null;
3744

3845
public layersToCreateNewFeaturesFrom = signal<AppLayerModel[]>([]);
3946

40-
private defaultTooltip = $localize `:@@core.edit.edit-feature-tooltip:Edit feature`;
47+
private defaultTooltip = $localize `:@@core.edit.edit:Edit feature`;
4148
private notLoggedInTooltip = $localize `:@@core.edit.require-login-tooltip:You must be logged in to edit.`;
4249
private noLayersTooltip = $localize `:@@core.edit.no-editable-layers-tooltip:There are no editable layers. Enable a layer to start editing.`;
4350

projects/core/src/lib/components/edit/state/edit.effects.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as EditActions from './edit.actions';
44
import { filter, map, switchMap } from 'rxjs';
55
import { FeatureInfoService } from '../../feature-info';
66
import { withLatestFrom } from 'rxjs/operators';
7-
import { selectEditActive, selectSelectedEditLayer } from './edit.selectors';
7+
import { selectEditActive, selectSelectedCopyLayer, selectSelectedEditLayer } from './edit.selectors';
88
import { Store } from '@ngrx/store';
99
import { activateTool } from '../../toolbar/state/toolbar.actions';
1010
import { ToolbarComponentEnum } from '../../toolbar/models/toolbar-component.enum';
@@ -36,9 +36,9 @@ export class EditEffects {
3636
public loadCopyFeatures$ = createEffect(() => {
3737
return this.actions$.pipe(
3838
ofType(EditActions.loadCopyFeatures),
39-
withLatestFrom(this.store$.select(selectSelectedEditLayer)),
40-
switchMap(([ action, editLayer ]) => {
41-
return this.featureInfoService.getFeaturesForLayer$(action.coordinates, editLayer, action.pointerType).pipe(
39+
withLatestFrom(this.store$.select(selectSelectedCopyLayer)),
40+
switchMap(([ action, copyLayer ]) => {
41+
return this.featureInfoService.getFeaturesForLayer$(action.coordinates, copyLayer, action.pointerType).pipe(
4242
map(result => {
4343
if (!result) {
4444
return EditActions.loadCopyFeaturesFailed({});

0 commit comments

Comments
 (0)