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

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

  agentArr = [];
  deptArr = [];

  constructor(bsModalRef: BsModalRef, fb: FormBuilder) { 
    super(bsModalRef);
    this.detailForm = fb.group({
      'agent_id': [null, Validators.compose([Validators.required])],
      'dept_id': [null, Validators.compose([Validators.required])]
    });
  }

  ngOnInit() {
    AjaxService.requestArray('conf/agent/all.htm', {}, (array) => {
      this.agentArr = array;
    });
    AjaxService.requestArray('frame/dept/all.htm', {}, (array) => {
      this.deptArr = array;
    });
  }

}
