<div class="employee-webapp">
  <label class="label">Webapp Liste</label>
  <section class="toolbar">
    <div class="toolbar-button-row">
      <div class="toolbar-flex-container">
        <button mat-icon-button title="Hinzufügen" (click)=addItem()
          [disabled]="!this.employeeDetails.entity.isActive || !employeeDetails.inNotViewMode || !employeeWebappList.focusedEntityShadowed.enabledNewButton()">
          <mat-icon>add</mat-icon>
        </button>
        <button mat-icon-button title="Bearbeiten" (click)=editItem()
          [disabled]="!this.employeeDetails.entity.isActive || !employeeDetails.inNotViewMode || !employeeWebappList.focusedItem || !employeeWebappList.focusedEntityShadowed.enabledEditButton()">
          <mat-icon>edit</mat-icon>
        </button>
        <button mat-icon-button title="Löschen" class="toolbar-button-last" (click)=employeeWebappList.focusedEntityShadowed.delete()
          [disabled]="!this.employeeDetails.entity.isActive
                      || !employeeDetails.inNotViewMode
                      || !employeeWebappList.focusedItem
                      || !employeeWebappList.focusedEntityShadowed.enabledDeleteButton()">
          <mat-icon>delete</mat-icon>
        </button>
      </div>
    </div>
  </section>
  <dx-data-grid
    name="webappGrid"
    [class]="'grid'+(columnConfigList.withExport ? ' withexport' : '')"
    [dataSource]="employeeWebappList.items"
    keyExpr="entityId"
    [(focusedRowIndex)]=employeeWebappList.focusedItemGridIndex
    [focusedRowEnabled]="true"
    [autoNavigateToFocusedRow]="true"
    [(focusedRowKey)]="employeeWebappList.focusedItemId"
    [(selectedRowKeys)]="employeeWebappList.selectedItemIds"
    [showBorders]="true"
    [allowColumnResizing]="true"
    columnResizingMode="widget"
    noDataText="Keine Daten sind vorhanden"
    [renderAsync]="true"
    (onRowDblClick)="dblClick($event)"
    (onKeyDown)="$event.handled = $event.event.key==='Escape'; employeeWebappList.gridUpDownProcessing($event)"
    (onExporting)="globals.doExcelExportSimple($event, employeeWebappList.getExportFilename4List())">

    <dxo-export [enabled]="columnConfigList.withExport" [texts]="{exportAll: 'Excel Export'}"></dxo-export>
    <!-- <dxo-header-filter [visible]="true"></dxo-header-filter> -->
    <dxo-filter-row [visible]="true"></dxo-filter-row>
    <dxo-paging [enabled]="false"></dxo-paging>
    <dxo-scrolling mode="virtual"></dxo-scrolling>
    <dxo-load-panel [enabled]="true"></dxo-load-panel>
    <dxo-sorting mode="multiple"></dxo-sorting>
    <dxo-selection mode="none"></dxo-selection>

    <ng-container *ngFor="let column of columnConfigList.columns">
      <ng-container *ngIf="column.visible">
        <dxi-column
          [allowHeaderFiltering]=column.allowHeaderFiltering
          [dataField]=column.dataField
          [dataType]=column.dataType
          [caption]=column.caption
          [width]=column.width
          [sortIndex]=column.sortIndex
          [sortOrder]=column.sortOrder
          [visibleIndex]=column.visibleIndex
          [visible]=column.visible
          [fixed]=column.fixed
          [headerCellTemplate]=column.headerCellTemplate
          [cellTemplate]=column.cellTemplate
          [allowSorting]=column.allowSorting
          [calculateCellValue]=column.calculateCellValue
          [calculateDisplayValue]=column.calculateDisplayValue
          [calculateGroupValue]=column.calculateGroupValue
          [calculateSortValue]=column.calculateSortValue
          [alignment]=column.alignment>
          <dxo-format *ngIf="column.dataType == 'date'" [type]=localeService.dateFormat></dxo-format>
          <dxo-format *ngIf="column.dataType == 'datetime'" [type]=localeService.dateTimeFormat></dxo-format>
          <!-- <dxo-lookup *ngIf="column.dataField === 'webAppId'" [dataSource]="{store:appDataService.webAppList?.items, sort:'webAppName'}" valueExpr="entityId" displayExpr="webAppName"></dxo-lookup> -->
          <!-- <dxo-lookup *ngIf="column.dataField === 'webAppId'" [dataSource]="appDataService.webAppList?.items" valueExpr="entityId" displayExpr="webAppName"></dxo-lookup> -->
          <!-- <dxo-lookup *ngIf="column.dataField === 'departmentId'" [dataSource]="appDataService.departmentList?.items" valueExpr="entityId" displayExpr="departmentName"></dxo-lookup>
          <dxo-lookup *ngIf="column.dataField === 'webAppRoleId'" [dataSource]="appDataService.roleList?.items" valueExpr="entityId" displayExpr="webAppRoleName"></dxo-lookup> -->
        </dxi-column>
      </ng-container>
    </ng-container>

    <div *dxTemplate="let cell of 'numberTemplate_0'">
      {{cell.value | number:'1.0-0':culture}}
    </div>
    <div *dxTemplate="let cell of 'numberTemplate_1'">
      {{cell.value | number:'1.1-1':culture}}
    </div>
    <div *dxTemplate="let cell of 'numberTemplate_2'">
      {{cell.value | number:'1.2-2':culture}}
    </div>
    <div *dxTemplate="let cell of 'numberTemplate_3'">
      {{cell.value | number:'1.3-3':culture}}
    </div>
  </dx-data-grid>
</div>
