import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';

@Component({
  selector: 'app-getbfo-newform',
  templateUrl: './getbfo-newform.component.html',
  styleUrls: ['./getbfo-newform.component.css']
})
export class GETBFONEWFORMComponent implements OnInit {

  public formGroup: FormGroup;
  constructor() { 
    this.formGroup = this.createFormGroup();
  }

  private createFormGroup(){
    return new FormGroup({
      step : new FormControl('', Validators.required),
      multi_data : new FormControl(false),
      table_name: new FormControl({value: '', disabled: true}),
      num_cols: new FormControl(2),
      form : new FormControl([]),
    });
  }

  ngOnInit(): void {

  }

  public disabledInputName(){
    if (this.multi_data?.value) {
      this.table_name?.disable();
      this.table_name?.setValue('');
    }else{
      this.table_name?.enable();
    }
  }

  get multi_data() {
    return this.formGroup.get('multi_data');
  }
  get table_name() {
    return this.formGroup.get('table_name');
  }

}
