Browse Source
Fixed time unit input validation and unwanted dirty state when loading a value (#15822)
* Fixed time unit input validation and unwanted dirty state when loading a value
* Code improvements
pull/15851/head
Maksym Tsymbarov
3 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
11 additions and
5 deletions
-
ui-ngx/src/app/shared/components/time-unit-input.component.ts
|
|
@ -206,15 +206,13 @@ export class TimeUnitInputComponent implements ControlValueAccessor, Validator, |
|
|
writeValue(sec: number) { |
|
|
writeValue(sec: number) { |
|
|
if (sec !== this.modelValue) { |
|
|
if (sec !== this.modelValue) { |
|
|
if (isDefinedAndNotNull(sec) && isNumeric(sec) && Number(sec) !== 0) { |
|
|
if (isDefinedAndNotNull(sec) && isNumeric(sec) && Number(sec) !== 0) { |
|
|
this.timeInputForm.patchValue(this.parseTime(sec), {emitEvent: true}); |
|
|
this.timeInputForm.patchValue(this.parseTime(sec), {emitEvent: false}); |
|
|
this.modelValue = sec; |
|
|
this.modelValue = sec; |
|
|
} else { |
|
|
} else { |
|
|
this.timeInputForm.patchValue({ |
|
|
this.timeInputForm.patchValue(this.secondsModel(0), {emitEvent: false}); |
|
|
time: 0, |
|
|
|
|
|
timeUnit: TimeUnit.SECONDS |
|
|
|
|
|
}, {emitEvent: false}); |
|
|
|
|
|
this.modelValue = 0; |
|
|
this.modelValue = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
this.refreshTimeValidators(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -242,6 +240,14 @@ export class TimeUnitInputComponent implements ControlValueAccessor, Validator, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return this.secondsModel(value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private secondsModel(time: number): TimeUnitInputModel { |
|
|
|
|
|
return { |
|
|
|
|
|
time, |
|
|
|
|
|
timeUnit: TimeUnit.SECONDS |
|
|
|
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private createStepMultipleOfValidator(): ValidatorFn { |
|
|
private createStepMultipleOfValidator(): ValidatorFn { |
|
|
|