import { Component, Input, OnInit } from '@angular/core';
import { Department } from '@app_models/basedata/department';
import { AppBaseEntityListWrapper } from '@app_services/app.baseentitylist.wrapper';
import { AppDataService } from '@app_services/app.data.service';
import { DepartmentDataService } from '../department-data.service';
import { ColumnConfigList } from '@app_core/components/grid-config/columnconfiglist';
import { LocaleService } from '@app_core/services/localization/locale.service';
import { Globals } from '@app_core/services/globals';
import { ColumnConfig, EN_SortOrder } from '@app_core/components/grid-config/columnconfig';

@Component({
  selector: 'app-department-list',
  templateUrl: './department-list.component.html',
  styleUrls: ['./department-list.component.scss']
})
export class DepartmentListComponent implements OnInit {
  @Input() public dataSource: AppBaseEntityListWrapper<Department>;

  public columnConfigList: ColumnConfigList = new ColumnConfigList();


  constructor(
    public departmentDataService: DepartmentDataService,
    public appDataService: AppDataService,
    public localeService: LocaleService,
    public globals: Globals,
  ) {
  }

  ngOnInit() {
    this.initColumns();
  }

  initColumns() {
    let col: ColumnConfig;
    col = this.columnConfigList.addNumber('Id', 'departmentId', 5);
    col = this.columnConfigList.add('Name', 'departmentName', 13);
    col.sortIndex = 0;
    col.sortOrder = EN_SortOrder.asc;
    col.allowHeaderFiltering = true;
    col = this.columnConfigList.addNumber('Typ Id', 'departmentTypeId', 5);
    col = this.columnConfigList.addNumber('CostCentre Id', 'costCentreId', 5);
    col = this.columnConfigList.add('CostCentre', 'costCentre', 10);
    col = this.columnConfigList.add('Abteilungsleiter', 'headofDepartment', 18);
    col = this.columnConfigList.add('CEO', 'executiveDirector', 18);
    col = this.columnConfigList.add('COO', 'managingDirector', 18);
    col = this.columnConfigList.add('Folder', 'departmentNameFolder', 13);
    col = this.columnConfigList.add('AD-Group Name', 'adGroupDepartmentName', 13);
    col = this.columnConfigList.addNumber('Client Id', 'clientId', 5);
    col = this.columnConfigList.addBoolean('Virtual', 'isVirtual', 2);
    this.columnConfigList.recalcWidth();
  }


  public loadData() {
    this.departmentDataService.loadData();
  }

}
