<div *ngIf="object" layoutDirection="column" layoutDirection-xs="column" class="fl-content fl-content-min-height">
  <p class="fl-detail" i18n>Description: {{ object.description | nullValue }}</p>
  <p class="fl-detail" i18n>Number of clients in this group: {{ object.client_count }}</p>
  <table *ngIf="clients" class="full-width" mat-table [dataSource]="clients">
    <ng-container matColumnDef="id">
      <th mat-header-cell *matHeaderCellDef i18n>ID</th>
      <td class="position-relative" mat-cell *matCellDef="let client">
        <a [routerLink]="[config.getPanelUrl('clients-users/clients'), client.id]">
          {{client.id}}
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="name">
      <th mat-header-cell *matHeaderCellDef i18n>Name</th>
      <td mat-cell *matCellDef="let client">
        <a [routerLink]="[config.getPanelUrl('clients-users/clients'), client.id]">
          {{client.display || client.name}}
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="(actions)">
      <th mat-header-cell *matHeaderCellDef></th>
      <td mat-cell *matCellDef="let client">
        <app-object-actions [objectActions]="clientActions[client.id]" [maxVisibleActions]="2">
        </app-object-actions>
      </td>
    </ng-container>
    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
  </table>

  <div *ngIf="previousPage || nextPage" class="fl-margin-top">
    <button mat-button (click)="changePage('previous')"
            [disabled]="previousPage === false || loading === true" color="primary" i18n>
      Previous page
      <ng-container *ngIf="previousPage && loading !== true">({{currentPage - 1}})</ng-container>
    </button>
    <button mat-button (click)="changePage('next')"
            [disabled]="nextPage === false || loading === true" color="primary" i18n>
      Next page
      <ng-container *ngIf="nextPage && loading !== true">({{currentPage + 1}})</ng-container>
    </button>
  </div>
  <form appFormSubmit (ngSubmit)="addClientToGroup()"
        [formGroup]="clientForm" class="fl-margin-top half-width">
    <app-client-autocomplete [control]="clientForm.controls.client"
                             [optionsRetrieveParams]="{clientGroupId: object.id}"
                             forClientGroup>
    </app-client-autocomplete>
  </form>
  <div layoutDirection="row">
    <button [disabled]="!clientForm.controls.client.value['id']" (click)="addClientToGroup()"
            mat-button mat-raised-button color="primary" i18n>
      Add client to group
    </button>
  </div>
</div>
