import {Component, OnInit} from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import {DomSanitizer} from '@angular/platform-browser';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { FrameDetailComponent } from '../../../../frame/core/detail/frame.detail';

@Component({
  selector: 'app-conf-tracks-detail',
  templateUrl: './conf-tracks-detail.component.html',
  styleUrls: ['./conf-tracks-detail.component.scss']
})
export class ConfTracksDetailComponent extends FrameDetailComponent implements OnInit {

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, sanitizer: DomSanitizer) {
    super(bsModalRef, sanitizer);
    this.detailForm = fb.group({
      'variety_id': [null, Validators.compose([Validators.required])],
      'tracks_name': [null, Validators.compose([Validators.required, Validators.minLength(1), Validators.maxLength(256)])],
      'tracks_group': [null, Validators.compose([Validators.required, Validators.minLength(1), Validators.maxLength(64)])],
      'tracks_code': [null],
      'tracks_type': [null],
      'tracks_author': [null],
      'tracks_source': [null],
      // 'tracks_status': [null, Validators.compose([Validators.required])],
      'tracks_enrol_explain': [null, Validators.maxLength(2000)]
    });
  }

  ngOnInit() {

  }

  initDefautEntity() {
    if (this.detailMode === 'add') {
      this.currentEntity.tracks_status = 'Active';
    }
  }
}
