[4421] fixed toggle bug
This commit is contained in:
parent
1b36e5770a
commit
041ba57a08
@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user