import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {Dialog} from '../../../classes/base_components/dialog/dialog';
import {Http} from '@angular/http';
import {EditUsersComponent} from '../../user/users/edit-users/edit-users.component';
import {ListComponent} from '../../../classes/base_components/list/list.component';
import {UniversitiesService} from '../../../classes/resorcess/universities.service';
import {EditUniversitiesComponent} from './editUniversities/editUniversities.component';

@Component({
  selector: 'app-universities',
  templateUrl: './universities.component.html',
  styleUrls: ['./universities.component.scss']
})
export class UniversitiesComponent extends ListComponent implements OnInit {
  @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
  @ViewChild('filter_id') public filter_id_ref: TemplateRef<any>;
  @ViewChild('filter_units') public filter_units_ref: TemplateRef<any>;
// todo filter units bezar

  constructor(public universitiesService: UniversitiesService,
              public dialog: Dialog,
              public http: Http,
  ) {
    super(universitiesService, dialog, EditUniversitiesComponent, http);
    this.universitiesService.register();
  }

  ngOnInit() {
    this.columns = [
      {
        prop: 'name',
        name: 'نام',
        filter: this.filter_name_ref,
      },
      {
        prop: 'units',
        name: 'universities',
        filter: this.filter_units_ref,
        isRelationship: true,
        mustIncluded: true,
      },
      {
        prop: 'id',
        name: 'شناسه',
        filter: this.filter_id_ref,
      },
    ];
    super.ngOnInit();
  }
}
