import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; import { VisibilityRuleSource } from '../../visibility-rules/models/VisibilityRuleSource'; 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 { FieldBase } from './field-base'; import { RuleStyle } from '../../entities/common/rulestyle'; @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,private 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"); } }