aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-forms/form-reactive.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/client/src/app/shared/shared-forms/form-reactive.ts b/client/src/app/shared/shared-forms/form-reactive.ts
index 6b3a6c773..a19ffdd82 100644
--- a/client/src/app/shared/shared-forms/form-reactive.ts
+++ b/client/src/app/shared/shared-forms/form-reactive.ts
@@ -1,5 +1,5 @@
1 1
2import { FormGroup } from '@angular/forms' 2import { AbstractControl, FormGroup } from '@angular/forms'
3import { wait } from '@root-helpers/utils' 3import { wait } from '@root-helpers/utils'
4import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model' 4import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
5import { FormValidatorService } from './form-validator.service' 5import { FormValidatorService } from './form-validator.service'
@@ -44,6 +44,21 @@ export abstract class FormReactive {
44 } while (this.form.status === 'PENDING') 44 } while (this.form.status === 'PENDING')
45 } 45 }
46 46
47 protected markAllAsDirty (controlsArg?: { [ key: string ]: AbstractControl }) {
48 const controls = controlsArg || this.form.controls
49
50 for (const key of Object.keys(controls)) {
51 const control = controls[key]
52
53 if (control instanceof FormGroup) {
54 this.markAllAsDirty(control.controls)
55 continue
56 }
57
58 control.markAsDirty()
59 }
60 }
61
47 protected forceCheck () { 62 protected forceCheck () {
48 this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false) 63 this.onStatusChanged(this.form, this.formErrors, this.validationMessages, false)
49 } 64 }
@@ -59,7 +74,8 @@ export abstract class FormReactive {
59 this.onStatusChanged( 74 this.onStatusChanged(
60 form.controls[field] as FormGroup, 75 form.controls[field] as FormGroup,
61 formErrors[field] as FormReactiveErrors, 76 formErrors[field] as FormReactiveErrors,
62 validationMessages[field] as FormReactiveValidationMessages 77 validationMessages[field] as FormReactiveValidationMessages,
78 onlyDirty
63 ) 79 )
64 continue 80 continue
65 } 81 }