import {Component, OnInit} from '@angular/core';
import {timeEnd} from '@ngtools/webpack/src/benchmark';
import {FormBuilder, FormGroup} from '@angular/forms';

@Component({
    selector: 'smart-type-asets',
    templateUrl: './type-asets.component.html',
    styles: []
})
export class TypeAsetsComponent implements OnInit {

    title;
    isVisible;
    validateForm:FormGroup;

    constructor(private fb:FormBuilder) {
    }

    checkChange(){

    }

    ngOnInit() {
        this.initForm();
    }

    initForm(){
        this.validateForm = this.fb.group(
            {
                parentid:[null],
                name:[null],
                typeno:[null],
                tyoeDescribe:[null],
            }
        )
    }

    showAddModal(title) {
        this.isVisible = true;
        this.title = title;
    }

    showEditModal(title) {
        this.isVisible = true;
        this.title = title;
    }

    handleCancel() {
        for(let i in this.validateForm.controls){
            this.validateForm.controls[i].markAsDirty();
            this.validateForm.controls[i].updateValueAndValidity();
        }
        if(this.validateForm.invalid){
            return false;
        }
    }

    handleOk() {
        this.isVisible = false;
    }
}
