]>
Commit | Line | Data |
---|---|---|
5c5bcea2 | 1 | import { FormGroup } from '@angular/forms' |
7ed1edbb | 2 | import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model' |
5c5bcea2 | 3 | import { FormReactiveService, FormReactiveValidationMessages } from './form-reactive.service' |
d18d6478 | 4 | |
4b2f33f3 | 5 | export abstract class FormReactive { |
5c5bcea2 | 6 | protected abstract formReactiveService: FormReactiveService |
772d5642 | 7 | protected formChanged = false |
4b2f33f3 | 8 | |
d18d6478 | 9 | form: FormGroup |
26a008fe | 10 | formErrors: any // To avoid casting in template because of string | FormReactiveErrors |
d18d6478 | 11 | validationMessages: FormReactiveValidationMessages |
4b2f33f3 | 12 | |
d18d6478 | 13 | buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) { |
5c5bcea2 | 14 | const { formErrors, validationMessages, form } = this.formReactiveService.buildForm(obj, defaultValues) |
4b2f33f3 | 15 | |
d18d6478 C |
16 | this.form = form |
17 | this.formErrors = formErrors | |
18 | this.validationMessages = validationMessages | |
3866f1a0 C |
19 | } |
20 | ||
cc4bf76c | 21 | protected async waitPendingCheck () { |
5c5bcea2 | 22 | return this.formReactiveService.waitPendingCheck(this.form) |
3866f1a0 C |
23 | } |
24 | ||
5c5bcea2 C |
25 | protected markAllAsDirty () { |
26 | return this.formReactiveService.markAllAsDirty(this.form.controls) | |
8b69f9f0 C |
27 | } |
28 | ||
cc4bf76c | 29 | protected forceCheck () { |
5c5bcea2 | 30 | return this.formReactiveService.forceCheck(this.form, this.formErrors, this.validationMessages) |
bf57d5ee | 31 | } |
4b2f33f3 | 32 | } |