import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {RolesService} from '../../../classes/resorcess/roles.service';
import {ListComponent} from '../../../classes/base_components/list/list.component';
import {Dialog} from '../../../classes/base_components/dialog/dialog';
import {EditRolesComponent} from './edit-roles/edit-roles.component';
import {PermissionGroupsService, PermissionsService} from '../../../classes/resorcess/permissions.service';
import {Http} from '@angular/http';

@Component({
  selector: 'app-roles',
  templateUrl: './roles.component.html',
  styleUrls: ['./roles.component.scss']
})
export class RolesComponent extends ListComponent implements OnInit {
  @ViewChild('filter_id') public filter_id_ref: TemplateRef<any>;
  @ViewChild('filter_name') public filter_name_ref: TemplateRef<any>;
  @ViewChild('filter_slug') public filter_slug_ref: TemplateRef<any>;

  constructor(
    public listService: RolesService,
    public permissionsService: PermissionsService,
    public permissionGroupsService: PermissionGroupsService,
    public dialog: Dialog,
    public http: Http,
  ) {
    super(listService, dialog, EditRolesComponent, http);
    this.permissionsService.register();
    this.permissionGroupsService.register();
  }

  ngOnInit() {
    this.columns = [

      {
        prop: 'name',
        name: 'نام',
        filter: this.filter_name_ref,
      },
      {
        prop: 'slug',
        name: 'slug',
        filter: this.filter_slug_ref,
      },
      {
        prop: 'id',
        name: 'شناسه',
        filter: this.filter_id_ref,
      },
    ];
    super.ngOnInit();
  }

}
