import { Component , OnInit , Input , ViewChild , EventEmitter , Output } from '@angular/core' ; import { FormControl , FormGroup , Validators } from '@angular/forms' ; import { DocapiBuilderTypeStepBaseComponent } from './docapi-builder-type-step-base/docapi-builder-type-step-base.component' ; import { CmdbMode } from '../../../framework/modes.enum' ; @ Component ( { selector : 'cmdb-docapi-settings-builder-type-step' , templateUrl : './docapi-builder-type-step.component.html' , styleUrls : [ './docapi-builder-type-step.component.scss' ] } ) export class DocapiBuilderTypeStepComponent implements OnInit { @ Input ( ) set preData ( data ) { if ( data !== undefined ) { this . typeForm . patchValue ( data ) ; if ( data . template_parameters ) { this . typeParamPreData = data . template_parameters ; } } } @ Input ( ) public mode : CmdbMode ; public modes = CmdbMode ; public typeForm : FormGroup ; public readonly docTypeSelect : any [ ] = [ { label : 'Object Template' , content : 'OBJECT' , description : 'Template for single objects' } ] ; @ ViewChild ( 'typeparam' ) public typeParamComponent : DocapiBuilderTypeStepBaseComponent ; public typeParamPreData : any ; public typeValid : boolean = false ; public typeChildValid : boolean = false ; @ Output ( ) public formValidEmitter : EventEmitter < boolean > ; constructor ( ) { this . formValidEmitter = new EventEmitter < boolean > ( ) ; this . typeForm = new FormGroup ( { template_type : new FormControl ( '' , Validators . required ) } ) ; } public ngOnInit ( ) { this . typeForm . valueChanges . subscribe ( ( ) => { this . typeValid = this . typeForm . valid ; this . formValidEmitter . emit ( this . typeValid && this . typeChildValid ) ; } ) ; } }