refactor
This commit is contained in:
parent
5706dfaae8
commit
02e1ecfe82
@ -96,25 +96,18 @@ export class EditHotelComponent implements OnInit {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Object.keys(this.form.controls).forEach(controlName => {
|
Object.keys(this.form.controls).forEach(controlName => {
|
||||||
|
let debounce = 1000;
|
||||||
const control = this.form.get(controlName);
|
const control = this.form.get(controlName);
|
||||||
if (!control) {
|
if (!control) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
control?.valueChanges?.pipe(debounceTime(1000)).subscribe(() => {this.setErrorMessage(controlName, control)});
|
if (controlName === 'rating') {
|
||||||
});
|
debounce = 0;
|
||||||
|
|
||||||
this.form.controls['rating'].valueChanges.subscribe((value: number | null) => {
|
|
||||||
if (value === null) {
|
|
||||||
this.errorMsgs['rating'] = this.validationErrors['required'];
|
|
||||||
} else if (value < 0) {
|
|
||||||
this.errorMsgs['rating'] = this.validationErrors['min'];
|
|
||||||
} else if (value > 5) {
|
|
||||||
this.errorMsgs['rating'] = this.validationErrors['max'];
|
|
||||||
} else {
|
|
||||||
this.errorMsgs['rating'] = '';
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
control?.valueChanges?.pipe(debounceTime(debounce)).subscribe(() => {this.setErrorMessage(controlName, control)});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user