[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.showStrategyControl = this.fb.control(false);
|
||||||
|
|
||||||
this.reportStrategyFormGroup = this.fb.group({
|
this.reportStrategyFormGroup = this.fb.group({
|
||||||
type: [ReportStrategyType.OnReportPeriod, []],
|
type: [{ value: ReportStrategyType.OnReportPeriod, disabled: true }, []],
|
||||||
reportPeriod: [5000, [Validators.required]],
|
reportPeriod: [{ value: 5000, disabled: true }, [Validators.required]],
|
||||||
});
|
});
|
||||||
|
|
||||||
this.observeStrategyFormChange();
|
this.observeStrategyFormChange();
|
||||||
@ -106,6 +106,9 @@ export class ReportStrategyComponent implements ControlValueAccessor, OnDestroy
|
|||||||
if (this.isExpansionMode) {
|
if (this.isExpansionMode) {
|
||||||
this.showStrategyControl.setValue(!!reportStrategyConfig, {emitEvent: false});
|
this.showStrategyControl.setValue(!!reportStrategyConfig, {emitEvent: false});
|
||||||
}
|
}
|
||||||
|
if (reportStrategyConfig) {
|
||||||
|
this.reportStrategyFormGroup.enable({emitEvent: false});
|
||||||
|
}
|
||||||
const { type = ReportStrategyType.OnReportPeriod, reportPeriod = 5000 } = reportStrategyConfig ?? {};
|
const { type = ReportStrategyType.OnReportPeriod, reportPeriod = 5000 } = reportStrategyConfig ?? {};
|
||||||
this.reportStrategyFormGroup.setValue({ type, reportPeriod }, {emitEvent: false});
|
this.reportStrategyFormGroup.setValue({ type, reportPeriod }, {emitEvent: false});
|
||||||
this.onTypeChange(type);
|
this.onTypeChange(type);
|
||||||
@ -157,11 +160,10 @@ export class ReportStrategyComponent implements ControlValueAccessor, OnDestroy
|
|||||||
|
|
||||||
private onTypeChange(type: ReportStrategyType): void {
|
private onTypeChange(type: ReportStrategyType): void {
|
||||||
const reportPeriodControl = this.reportStrategyFormGroup.get('reportPeriod');
|
const reportPeriodControl = this.reportStrategyFormGroup.get('reportPeriod');
|
||||||
const isDisabled = reportPeriodControl.disabled;
|
|
||||||
|
|
||||||
if (type === ReportStrategyType.OnChange && !isDisabled) {
|
if (type === ReportStrategyType.OnChange) {
|
||||||
reportPeriodControl.disable({emitEvent: false});
|
reportPeriodControl.disable({emitEvent: false});
|
||||||
} else if (isDisabled) {
|
} else if (!this.isExpansionMode || this.showStrategyControl.value) {
|
||||||
reportPeriodControl.enable({emitEvent: false});
|
reportPeriodControl.enable({emitEvent: false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user