]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-forms/form-reactive.ts
Merge branch 'release/5.0.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-forms / form-reactive.ts
1 import { FormGroup } from '@angular/forms'
2 import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
3 import { FormReactiveService, FormReactiveValidationMessages } from './form-reactive.service'
4
5 export abstract class FormReactive {
6 protected abstract formReactiveService: FormReactiveService
7 protected formChanged = false
8
9 form: FormGroup
10 formErrors: any // To avoid casting in template because of string | FormReactiveErrors
11 validationMessages: FormReactiveValidationMessages
12
13 buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {
14 const { formErrors, validationMessages, form } = this.formReactiveService.buildForm(obj, defaultValues)
15
16 this.form = form
17 this.formErrors = formErrors
18 this.validationMessages = validationMessages
19 }
20
21 protected async waitPendingCheck () {
22 return this.formReactiveService.waitPendingCheck(this.form)
23 }
24
25 protected markAllAsDirty () {
26 return this.formReactiveService.markAllAsDirty(this.form.controls)
27 }
28
29 protected forceCheck () {
30 return this.formReactiveService.forceCheck(this.form, this.formErrors, this.validationMessages)
31 }
32 }