import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {ListComponent} from '../../../classes/base_components/list/list.component';
import {Dialog} from '../../../classes/base_components/dialog/dialog';
import {Http} from '@angular/http';
import {CitiesService} from '../../../classes/resorcess/cities.service';
import {EditCitiesComponent} from './editCities/editCities.component';

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


  constructor(public citiesService: CitiesService,
              public dialog: Dialog,
              public http: Http,
  ) {
    super(citiesService, dialog, EditCitiesComponent, http);
    this.citiesService.register();
  }

  ngOnInit() {
    this.columns = [
      {
        prop: 'name',
        name: 'نام',
        filter: this.filter_name_ref,
      },
      {
        prop: 'prefix_code',
        name: 'موبایل',
        filter: this.filter_prefix_code_ref,
      },
      {
        prop: 'id',
        name: 'شناسه',
        filter: this.filter_id_ref,
      },
    ];
    super.ngOnInit();
  }
}

