Browse Source

Merge pull request #8503 from vvlladd28/bug/widget-config/change-datasource-type

Fixed incorrect updated dataSource validator when changing dataSource type
pull/8506/head
Igor Kulikov 3 years ago
committed by GitHub
parent
commit
762412f964
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.html
  2. 8
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts

2
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"

8
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();

Loading…
Cancel
Save