<div class="header-container">
  <button mat-icon-button color="primary" (click)="iniciarTour()">
    <mat-icon>help</mat-icon>
  </button>
  <div class="header-container-title">
    <h2 joyrideStep="titleStep" text="Desde esta pantalla podrás ver y administrar los menus exitentes.">
      Administrar menús</h2>
  </div>
  <div class="images-button-row">
    <button class="action-button" (click)="addMenu()" joyrideStep="addStep"
      text="Utiliza este botón para añadir un nuevo menu.">Añadir menú</button>
  </div>
</div>

<div class="search-container">
  <mat-form-field appearance="fill" class="search-string">
    <mat-label>Buscar nombre de menú</mat-label>
    <input matInput placeholder="Búsqueda" [(ngModel)]="filters['name']" (keyup.enter)="search()"
      i18n-placeholder="@@searchPlaceholder">
    <mat-icon matSuffix>search</mat-icon>
    <mat-hint>Pulsar 'enter' para buscar</mat-hint>
  </mat-form-field>
</div>

<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
  <ng-container *ngFor="let column of columns" [matColumnDef]="column.columnDef">
    <th mat-header-cell *matHeaderCellDef> {{ column.header }} </th>
    <td mat-cell *matCellDef="let menu">
      <ng-container *ngIf="column.columnDef !== 'isDefault'">
        {{ column.cell(menu) }}
      </ng-container>
      <ng-container *ngIf="column.columnDef === 'isDefault'">
        <mat-icon [color]="menu[column.columnDef] ? 'primary' : 'warn'">
          {{ menu[column.columnDef] ? 'check_circle' : 'cancel' }}
        </mat-icon>
      </ng-container>
    </td>
  </ng-container>

  <ng-container matColumnDef="actions">
    <th mat-header-cell *matHeaderCellDef i18n="@@columnActions" style="text-align: center;">Acciones</th>
    <td mat-cell *matCellDef="let menu" style="text-align: center;">
      <button mat-icon-button color="primary" (click)="editMenu($event, menu)" i18n="@@editImage">
        <mat-icon>edit</mat-icon></button>
      <button mat-icon-button color="warn" (click)="deleteMenu($event, menu)">
        <mat-icon i18n="@@deleteElementTooltip">delete</mat-icon>
      </button>
    </td>
  </ng-container>
  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
  <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>

<div class="paginator-container">
  <mat-paginator [length]="length" [pageSize]="itemsPerPage" [pageIndex]="page" [pageSizeOptions]="[5, 10, 20, 40, 100]"
    (page)="onPageChange($event)">
  </mat-paginator>
</div>