From da124a27a482f60915afacc14551f7e8254ab963 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Mon, 8 May 2023 17:32:08 +0300 Subject: [PATCH] UI: Fixed incorrect updated dataSource validator when changing dataSource type --- .../home/components/widget/widget-config.component.html | 2 +- .../home/components/widget/widget-config.component.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html index df7dd942a7..7d39455f36 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.html @@ -156,7 +156,7 @@ [widgetType]="widgetType" [datasourceType]="datasourceControl.get('type').value" [maxDataKeys]="modelValue?.typeParameters?.maxDataKeys" - [optDataKeys]="dataKeysOptional(datasourceControl.value)" + [optDataKeys]="dataKeysOptional(datasourceControl.get('type').value)" [aliasController]="aliasController" [datakeySettingsSchema]="modelValue?.dataKeySettingsSchema" [dataKeySettingsDirective]="modelValue?.dataKeySettingsDirective" diff --git a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts index 5cbcf94826..1514c1b929 100644 --- a/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts @@ -538,17 +538,17 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont } } - public dataKeysOptional(datasource?: Datasource): boolean { + public dataKeysOptional(type?: DatasourceType): boolean { if (this.widgetType === widgetType.timeseries && this.modelValue?.typeParameters?.hasAdditionalLatestDataKeys) { return true; } else { return this.modelValue.typeParameters && this.modelValue.typeParameters.dataKeysOptional - && datasource?.type !== DatasourceType.entityCount && datasource?.type !== DatasourceType.alarmCount; + && type !== DatasourceType.entityCount && type !== DatasourceType.alarmCount; } } private buildDatasourceForm(datasource?: Datasource): UntypedFormGroup { - const dataKeysRequired = !this.dataKeysOptional(datasource); + const dataKeysRequired = !this.dataKeysOptional(datasource?.type); const datasourceFormGroup = this.fb.group( { type: [datasource ? datasource.type : null, [Validators.required]], @@ -569,7 +569,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, Cont datasourceFormGroup.get('entityAliasId').setValidators( (type === DatasourceType.entity || type === DatasourceType.entityCount) ? [Validators.required] : [] ); - const newDataKeysRequired = !this.dataKeysOptional(datasourceFormGroup.value); + const newDataKeysRequired = !this.dataKeysOptional(type); datasourceFormGroup.get('dataKeys').setValidators(newDataKeysRequired ? [Validators.required] : []); datasourceFormGroup.get('entityAliasId').updateValueAndValidity(); datasourceFormGroup.get('dataKeys').updateValueAndValidity();