52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { Field } from '../../models/Field';
|
|
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
|
import { FormGroup, ValidatorFn, AbstractControl, Validators } from '@angular/forms';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { VisibilityRulesService } from '../../utilities/visibility-rules/visibility-rules.service';
|
|
|
|
|
|
@Component({
|
|
selector: 'df-field',
|
|
templateUrl: './dynamic-form-field.component.html',
|
|
// styles: ['.checkBoxLabelCustom {font-weight: 700;}']
|
|
styleUrls: [
|
|
'./dynamic-form-field.component.css'
|
|
],
|
|
encapsulation: ViewEncapsulation.None
|
|
})
|
|
|
|
export class DynamicFormFieldComponent implements OnInit {
|
|
@Input() field: Field;
|
|
@Input() form: FormGroup;
|
|
@Input() pathName: string;
|
|
@Input() path: string;
|
|
|
|
constructor(private route: ActivatedRoute, public visibilityRulesService: VisibilityRulesService) { }
|
|
|
|
ngOnInit() {
|
|
this.form.get('value').valueChanges.subscribe(item => {
|
|
this.visibilityRulesService.updateValueAndVisibility(this.field.id)
|
|
})
|
|
}
|
|
|
|
ngOnChanges(changeRecord) {
|
|
|
|
}
|
|
|
|
clearInput() {
|
|
}
|
|
|
|
get isValid() {
|
|
return this.form.get("value").valid;
|
|
}
|
|
get isValidRequired() {
|
|
return this.form.get("value").hasError("required");
|
|
}
|
|
get isValidPattern() {
|
|
return this.form.get("value").hasError("pattern");
|
|
}
|
|
get isValidCustom() {
|
|
return this.form.get("value").hasError("forbiddenName");
|
|
}
|
|
}
|