aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms/dynamic-form-field.component.ts
blob: e1a1f80340205ffacd83bd88760a6a51f98ace80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Component, Input } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { RegisterClientFormFieldOptions } from '@shared/models'

@Component({
  selector: 'my-dynamic-form-field',
  templateUrl: './dynamic-form-field.component.html',
  styleUrls: [ './dynamic-form-field.component.scss' ]
})

export class DynamicFormFieldComponent {
  @Input() form: FormGroup
  @Input() formErrors: any
  @Input() setting: RegisterClientFormFieldOptions

  hasDedicatedFormError () {
    const dedicated = new Set<RegisterClientFormFieldOptions['type']>([
      'input-checkbox',
      'input',
      'select',
      'input-textarea'
    ])

    return dedicated.has(this.setting.type)
  }
}