import { Component , OnDestroy , OnInit } from '@angular/core' ; import { ConfigEditBaseComponent } from '../config.edit' ; import { FormControl , Validators } from '@angular/forms' ; import { ReplaySubject } from 'rxjs' ; import { ValidRegexValidator } from '../../../../../layout/validators/valid-regex-validator' ; @ Component ( { selector : 'cmdb-text-field-edit' , templateUrl : './text-field-edit.component.html' , styleUrls : [ './text-field-edit.component.scss' ] } ) export class TextFieldEditComponent extends ConfigEditBaseComponent implements OnInit , OnDestroy { protected protected subscriber : ReplaySubject < void > = new ReplaySubject < void > ( ) ; public requiredControl : FormControl = new FormControl ( false ) ; public nameControl : FormControl = new FormControl ( '' , Validators . required ) ; public labelControl : FormControl = new FormControl ( '' , Validators . required ) ; public descriptionControl : FormControl = new FormControl ( undefined ) ; public regexControl : FormControl = new FormControl ( undefined , ValidRegexValidator ) ; public placeholderControl : FormControl = new FormControl ( undefined ) ; public valueControl : FormControl = new FormControl ( undefined ) ; public helperTextControl : FormControl = new FormControl ( undefined ) ; constructor ( ) { super ( ) ; } public ngOnInit ( ) { this . form . addControl ( 'required' , this . requiredControl ) ; this . form . addControl ( 'name' , this . nameControl ) ; this . form . addControl ( 'label' , this . labelControl ) ; this . form . addControl ( 'description' , this . descriptionControl ) ; this . form . addControl ( 'regex' , this . regexControl ) ; this . form . addControl ( 'placeholder' , this . placeholderControl ) ; this . form . addControl ( 'value' , this . valueControl ) ; this . form . addControl ( 'helperText' , this . helperTextControl ) ; this . disableControlOnEdit ( this . nameControl ) ; this . patchData ( this . data , this . form ) ; } public ngOnDestroy ( ) { this . subscriber . next ( ) ; this . subscriber . complete ( ) ; } }