import { Component, OnInit } from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import {DomSanitizer} from '@angular/platform-browser';
import {BsModalRef} from 'ngx-bootstrap';
import {FrameEditComponent} from '../../../../../frame/core/FrameEditComponent';
import {datetimeValidator} from '../../../../../../shared/validator/datetime.validator';


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

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, sanitizer: DomSanitizer) {
    debugger;
    super(bsModalRef, sanitizer);
    this.valForm = fb.group({
      'school_code': [null, Validators.compose([Validators.required, Validators.minLength(4), Validators.maxLength(10)])],
      'school_name': [null, Validators.compose([Validators.required, Validators.minLength(2), Validators.maxLength(256)])],
      'school_addr': [null, Validators.compose([Validators.required, Validators.minLength(10), Validators.maxLength(500)])],
      'school_tel': [null, Validators.compose([Validators.required, Validators.minLength(8), Validators.maxLength(12)])],
      'school_fax': [null, Validators.maxLength(12)],
      'school_url': [null, Validators.maxLength(128)],
      'school_short_name': [null, Validators.maxLength(128)],
      'enrol_start_time': [null, Validators.compose([datetimeValidator])],
      'enrol_end_time': [null, Validators.compose([datetimeValidator])],
      'ticket_start_time': [null, Validators.compose([datetimeValidator])],
      'ticket_end_time': [null, Validators.compose([datetimeValidator])],
      'ticket_title': [null, Validators.compose([Validators.required, Validators.minLength(0), Validators.maxLength(256)])],
      'ticket_note': [null, Validators.maxLength(2000)]
    });
  }

  ngOnInit() {
  }

  initDefautEntity() {
    if (this.editModel === 'add') {

    } else {
      if (this.currentEntity.exam_start_date) {

      }
    }
  }

}
