import {Component, OnInit, ChangeDetectionStrategy, Input, Output, EventEmitter, OnChanges} from '@angular/core';
import { BaseList } from 'src/app/core/base/base-list';
import {AppTokenService} from '../../../../../core/service/security/app-token.service';
import {OBJECT} from '../../../../../core/enum/role';

@Component({
  selector: 'app-set-exam-information-list',
  templateUrl: './set-exam-information-list.component.html',
  styleUrls: ['./set-exam-information-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class SetExamInformationListComponent extends BaseList implements OnInit, OnChanges {
  @Input() subjectList: any = [];
  role = [];
  roleConfig = OBJECT;
  @Output() edit = new EventEmitter();
  @Output() view = new EventEmitter();
    @Output() expand = new EventEmitter();
    @Output() export = new EventEmitter();
  @Output() delete = new EventEmitter();
  column = [
    '1',
    'testing_information_code',
    '8',
    'testing_information_name',
    'academic_semester_code',
    'academic_year_code',
    'created_by',
    '6',
      'is_open',
    'created_datetime',
    '7',
      '9'
  ];
  reload: boolean;

  constructor(
    private appTokenSV: AppTokenService
  ) {
    super();
  }

  ngOnInit(): void {
    this.role = this.appTokenSV.user.rights;
    this.reload = false;
    setTimeout(() => {
      this.reload = true;
    }, 2000);
  }

  ngOnChanges(){
    this.subjectList = this.updateMatTable(this.subjectList ? this.subjectList : []);
  }

  onEdit(id){
    this.edit.emit(id);
  }

    onView(id){
        this.view.emit(id);
    }

    onExportExcel(id){
        this.export.emit(id);
    }

  onExpand(id){
    this.expand.emit(id);
  }

  onDelete(id){
    this.delete.emit(id);
  }

}
