import { Component, OnInit } from '@angular/core';
import {FormBuilder, Validators} from '@angular/forms';
import {FrameAbstractComponent} from '../../../frame/FrameAbstractComponent';
import {FrameRequest} from '../../../../shared/frame/frame-request';
import {CustomValidators} from 'ng2-validation';

@Component({
  selector: 'app-cf-aspect',
  templateUrl: './cf-aspect.component.html',
  styleUrls: ['./cf-aspect.component.scss']
})
export class CfAspectComponent  extends FrameAbstractComponent {

  initAspect = {aspect_status: 'Active'};
  majorArray: any;
  feeArray: any;


  constructor(fb: FormBuilder) {
    super();
    this.valForm = fb.group({
      'aspect_name': [null, Validators.compose([Validators.required, CustomValidators.rangeLength([1, 32])])],
      'major_id': [null, Validators.required],
      'aspect_fee_id': [null, Validators.required],
      'aspect_code': [null, null],
      'aspect_ticket_rule': [null, null],
    });
  }

  optrAspect(step: string, entity: string , url?: string) {
    FrameRequest.requestMap('cf/aspect/optr/init.htm', {}, (map) => {
      this.majorArray = map['MajorArray'];
      this.feeArray = map['FeeArray'];
      this.goViewStep(step, entity, url, () => {
        delete(this.entity.fee);
      });
    });
  }


}
