import {ListComponent} from '../../../classes/base_components/list/list.component';
import {Dialog} from '../../../classes/dialog';
import {Component, OnInit, TemplateRef, ViewChild} from '@angular/core';
import {ProductsService} from './products.service';
import {EditProductComponent} from './edit-product/edit-product.component';
import {Http} from '@angular/http';


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

  /**
   *
   * @param {ProductsService} listService  inject kardan ptoduct service
   * @param {Dialog} dialog  for dialog
   */
  constructor(
    protected listService: ProductsService,
    protected dialog: Dialog,
    protected http: Http,
  ) {
    super(listService, dialog, EditProductComponent, http);
    this.listService.register();
  }

  ngOnInit() {
    this.columns = [
      {
        prop: 'price',
        name: 'قیمت پایه',
        filter: this.filter_price_ref,
      }, {
        prop: 'name',
        name: 'نام محصول',
        filter: this.filter_name_ref,
      },
      {
        prop: 'id',
        name: 'شناسه',
        filter: this.filter_id_ref,
      },

    ];
    super.ngOnInit();
  }

}
