<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 flavors in this group: {{ object.flavor_count }}</p>
  <table *ngIf="flavors" class="full-width" mat-table [dataSource]="flavors">
    <ng-container matColumnDef="id">
      <th mat-header-cell *matHeaderCellDef i18n>ID</th>
      <td class="position-relative" mat-cell *matCellDef="let flavor">
        <a [routerLink]="[config.getPanelUrl('openstack/flavors'), flavor.id]">
          {{flavor.flavor_id}}
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="name">
      <th mat-header-cell *matHeaderCellDef i18n>Name</th>
      <td mat-cell *matCellDef="let flavor">
        <a [routerLink]="[config.getPanelUrl('openstack/flavors'), flavor.id]">
          {{flavor.name}}
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="region">
      <th mat-header-cell *matHeaderCellDef i18n>Region</th>
      <td mat-cell *matCellDef="let flavor">
        <a [routerLink]="[config.getPanelUrl('openstack/flavors'), flavor.id]">
          {{flavor.region }}
        </a>
      </td>
    </ng-container>
    <ng-container matColumnDef="(actions)">
      <th mat-header-cell *matHeaderCellDef></th>
      <td mat-cell *matCellDef="let flavor">
        <app-object-actions [objectActions]="flavorActions[flavor.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)="addFlavorToGroup()" [formGroup]="flavorForm" class="half-width fl-margin-top">
    <app-autocomplete [control]="flavorForm.controls.flavor"
                      [placeholderSelected]="flavorSelectedPlaceholder"
                      [placeholderUnselected]="flavorUnselectedPlaceholder"
                      [optionsService]="flavorsApiService"></app-autocomplete>
  </form>
  <div layoutDirection="row">
    <button [disabled]="!flavorForm.controls.flavor.value['id']" (click)="addFlavorToGroup()"
            mat-button mat-raised-button color="primary" i18n>
      Add flavor to group
    </button>
  </div>
</div>
