Merge pull request #13063 from vvlladd28/bug/map/switch-map-difference-type

Fix map settings not updating when switching between different map type widgets
This commit is contained in:
Igor Kulikov 2025-03-31 12:47:41 +03:00 committed by GitHub
commit 8b8fcb1311
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View File

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { Component, DestroyRef, forwardRef, Input, OnInit } from '@angular/core'; import { Component, DestroyRef, forwardRef, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { import {
ControlValueAccessor, ControlValueAccessor,
NG_VALIDATORS, NG_VALIDATORS,
@ -70,7 +70,7 @@ import { MatDialog } from '@angular/material/dialog';
} }
] ]
}) })
export class MapSettingsComponent implements OnInit, ControlValueAccessor, Validator { export class MapSettingsComponent implements OnInit, ControlValueAccessor, Validator, OnChanges {
mapControlPositions = mapControlPositions; mapControlPositions = mapControlPositions;
@ -205,6 +205,23 @@ export class MapSettingsComponent implements OnInit, ControlValueAccessor, Valid
} }
} }
ngOnChanges(changes: SimpleChanges) {
if (changes.trip) {
const tripChange = changes.trip;
if (!tripChange.firstChange && tripChange.currentValue !== tripChange.previousValue) {
if (this.trip) {
this.dataLayerMode = 'trips'
this.mapSettingsFormGroup.addControl('trips', this.fb.control(this.modelValue.trips), {emitEvent: false});
this.mapSettingsFormGroup.addControl('tripTimeline', this.fb.control(this.modelValue.tripTimeline), {emitEvent: false});
} else {
this.dataLayerMode = 'markers';
this.mapSettingsFormGroup.removeControl('trips', {emitEvent: false});
this.mapSettingsFormGroup.removeControl('tripTimeline', {emitEvent: false});
}
}
}
}
writeValue(value: MapSetting): void { writeValue(value: MapSetting): void {
this.modelValue = value; this.modelValue = value;
this.mapSettingsFormGroup.patchValue( this.mapSettingsFormGroup.patchValue(

View File

@ -47,6 +47,8 @@ export class MapWidgetSettingsComponent extends WidgetSettingsComponent {
const params = widgetConfig.typeParameters as any; const params = widgetConfig.typeParameters as any;
if (isDefinedAndNotNull(params.trip)) { if (isDefinedAndNotNull(params.trip)) {
this.trip = params.trip === true; this.trip = params.trip === true;
} else {
this.trip = false;
} }
} }