@ -17,11 +17,11 @@
import { Component , forwardRef , Input , OnInit } from '@angular/core' ;
import {
ControlValueAccessor ,
NG_VALIDATORS ,
NG_VALUE_ACCESSOR ,
UntypedFormBuilder ,
UntypedFormControl ,
UntypedFormGroup ,
NG_VALIDATORS ,
NG_VALUE_ACCESSOR ,
Validator
} from '@angular/forms' ;
import { PageComponent } from '@shared/components/page.component' ;
@ -31,6 +31,13 @@ import { TranslateService } from '@ngx-translate/core';
import {
CircleSettings ,
CommonMapSettings ,
defaultCircleSettings ,
defaultCommonMapSettings ,
defaultMapEditorSettings ,
defaultMapProviderSettings ,
defaultMarkerClusteringSettings ,
defaultMarkersSettings ,
defaultPolygonSettings ,
MapEditorSettings ,
MapProviders ,
MapProviderSettings ,
@ -41,7 +48,6 @@ import {
UnitedMapSettings
} from '@home/components/widget/lib/maps/map-models' ;
import { extractType } from '@core/utils' ;
// import { keys } from 'ts-transformer-keys';
import { IAliasController } from '@core/api/widget-api.models' ;
import { Widget } from '@shared/models/widget.models' ;
@ -140,13 +146,12 @@ export class MapSettingsComponent extends PageComponent implements OnInit, Contr
writeValue ( value : UnitedMapSettings ) : void {
this . modelValue = value ;
// TODO: ts-transformer
/ * c o n s t m a p P r o v i d e r S e t t i n g s = e x t r a c t T y p e < M a p P r o v i d e r S e t t i n g s > ( v a l u e , k e y s < M a p P r o v i d e r S e t t i n g s > ( ) ) ;
const commonMapSettings = extractType < CommonMapSettings > ( value , keys < CommonMapSettings > ( ) ) ;
const markersSettings = extractType < MarkersSettings > ( value , keys < MarkersSettings > ( ) ) ;
const polygonSettings = extractType < PolygonSettings > ( value , keys < PolygonSettings > ( ) ) ;
const circleSettings = extractType < CircleSettings > ( value , keys < CircleSettings > ( ) ) ;
const mapEditorSettings = extractType < MapEditorSettings > ( value , keys < MapEditorSettings > ( ) ) ;
const mapProviderSettings = extractType < MapProviderSettings > ( value , Object . keys ( defaultMapProviderSettings ) as ( keyof MapProviderSettings ) [ ] ) ;
const commonMapSettings = extractType < CommonMapSettings > ( value , Object . keys ( defaultCommonMapSettings ) as ( keyof CommonMapSettings ) [ ] ) ;
const markersSettings = extractType < MarkersSettings > ( value , Object . keys ( defaultMarkersSettings ) as ( keyof MarkersSettings ) [ ] ) ;
const polygonSettings = extractType < PolygonSettings > ( value , Object . keys ( defaultPolygonSettings ) as ( keyof PolygonSettings ) [ ] ) ;
const circleSettings = extractType < CircleSettings > ( value , Object . keys ( defaultCircleSettings ) as ( keyof CircleSettings ) [ ] ) ;
const mapEditorSettings = extractType < MapEditorSettings > ( value , Object . keys ( defaultMapEditorSettings ) as ( keyof MapEditorSettings ) [ ] ) ;
const formValue = {
mapProviderSettings ,
commonMapSettings ,
@ -158,9 +163,9 @@ export class MapSettingsComponent extends PageComponent implements OnInit, Contr
if ( this . routeMap ) {
formValue . routeMapSettings = extractType < PolylineSettings > ( value , [ 'strokeWeight' , 'strokeOpacity' ] ) ;
} else {
formValue . markerClusteringSettings = extractType < MarkerClusteringSettings > ( value , keys < MarkerClusteringSettings > ( ) ) ;
formValue . markerClusteringSettings = extractType < MarkerClusteringSettings > ( value , Object . keys ( defaultMarkerClusteringSettings ) as ( keyof MarkerClusteringSettings ) [ ] ) ;
}
this . mapSettingsFormGroup . patchValue ( formValue , { emitEvent : false } ) ; * /
this . mapSettingsFormGroup . patchValue ( formValue , { emitEvent : false } ) ;
this . updateValidators ( false ) ;
}