diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/report-strategy/report-strategy.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/report-strategy/report-strategy.component.ts index a4320f4a3d..fb0819d119 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/report-strategy/report-strategy.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/gateway/connectors-configuration/report-strategy/report-strategy.component.ts @@ -89,8 +89,8 @@ export class ReportStrategyComponent implements ControlValueAccessor, OnDestroy this.showStrategyControl = this.fb.control(false); this.reportStrategyFormGroup = this.fb.group({ - type: [ReportStrategyType.OnReportPeriod, []], - reportPeriod: [5000, [Validators.required]], + type: [{ value: ReportStrategyType.OnReportPeriod, disabled: true }, []], + reportPeriod: [{ value: 5000, disabled: true }, [Validators.required]], }); this.observeStrategyFormChange(); @@ -106,6 +106,9 @@ export class ReportStrategyComponent implements ControlValueAccessor, OnDestroy if (this.isExpansionMode) { this.showStrategyControl.setValue(!!reportStrategyConfig, {emitEvent: false}); } + if (reportStrategyConfig) { + this.reportStrategyFormGroup.enable({emitEvent: false}); + } const { type = ReportStrategyType.OnReportPeriod, reportPeriod = 5000 } = reportStrategyConfig ?? {}; this.reportStrategyFormGroup.setValue({ type, reportPeriod }, {emitEvent: false}); this.onTypeChange(type); @@ -157,11 +160,10 @@ export class ReportStrategyComponent implements ControlValueAccessor, OnDestroy private onTypeChange(type: ReportStrategyType): void { const reportPeriodControl = this.reportStrategyFormGroup.get('reportPeriod'); - const isDisabled = reportPeriodControl.disabled; - if (type === ReportStrategyType.OnChange && !isDisabled) { + if (type === ReportStrategyType.OnChange) { reportPeriodControl.disable({emitEvent: false}); - } else if (isDisabled) { + } else if (!this.isExpansionMode || this.showStrategyControl.value) { reportPeriodControl.enable({emitEvent: false}); } }