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-exam-subject-score-detail',
  templateUrl: './exam-subject-score-detail.component.html',
  styleUrls: ['./exam-subject-score-detail.component.scss']
})
export class ExamSubjectScoreDetailComponent extends FrameDetailComponent implements OnInit {

  subjectArray = [];

  constructor(bsModalRef: BsModalRef, fb: FormBuilder, sanitizer: DomSanitizer) { 
    super(bsModalRef, sanitizer);
    this.detailForm = fb.group({
      'score_name' : [null, Validators.required],
      'score_max': [null, Validators.compose([Validators.required, Validators.min(0), Validators.max(100)])],
      'score_min': [null, Validators.compose([Validators.required, Validators.min(0), Validators.max(100)])],
      'score_tick': [null, Validators.compose([Validators.required, Validators.min(0), Validators.max(10)])],
      'score_level': [null, Validators.required],
      'master_flag': [null, null],
      'range': [null, null],
    });
  }

  ngOnInit() {
  }

  initDefautEntity() {
    for(const subject of this.ResponseArray) {
      subject.full_subject_name = subject.subject_id + '|' + subject.subject_name;
    }
    let all = {subject_id : 0, full_subject_name : '所有'};
    this.ResponseArray.splice(0, 0, all);
  }

}
