<table mat-table [dataSource]="courses" class="mat-elevation-z8 full-width-table no-right-padding">

    <!--- Note that these columns can be defined in any order.
          The actual rendered columns are set as a property on the row definition" -->
  
    <!-- Date Column -->
    <ng-container matColumnDef="date">
      <th mat-header-cell *matHeaderCellDef> Termín </th>
      <td mat-cell *matCellDef="let element"> {{element.dateStart | date:"d.M."}} - {{element.dateEnd | date:"d.M.Y"}} </td>
    </ng-container>
  
    <!-- Class Column -->
    <ng-container matColumnDef="class">
      <th mat-header-cell *matHeaderCellDef> Třída </th>
      <td mat-cell *matCellDef="let element"> {{element.class}} </td>
    </ng-container>

    <!-- Theme Column -->
    <ng-container matColumnDef="themeName">
        <th mat-header-cell *matHeaderCellDef> Téma </th>
        <td mat-cell *matCellDef="let element"> {{ getThemeNameById(element.themeId) }} </td>
      </ng-container>

    <!-- Class Column -->
    <ng-container matColumnDef="information">
      <th mat-header-cell *matHeaderCellDef> Další informace </th>
      <td mat-cell *matCellDef="let element" matTooltip="{{element.information}}"> {{ (element.information.length>60)? (element.information | slice:0:60)+'...':(element.information) }} </td>
    </ng-container>

    <!-- Link Column -->
    <ng-container matColumnDef="questionnaire">
      <th mat-header-cell *matHeaderCellDef> Dotazník před kurzem </th>
      <td mat-cell *matCellDef="let element">
        <a mat-raised-button color="primary" *ngIf="element.questionnaire == null" routerLink="/{{questionnaireLink}}/{{element.ID}}" 
          matTooltip="Dotazník je vhodné vyplnit zhruba 2 až 3 týdny před kurzem">Vyplnit dotazník</a>
        <a mat-raised-button *ngIf="element.questionnaire != null" routerLink="/{{questionnaireLink}}/{{element.ID}}">Zobrazit odpovědi</a>
      </td>
    </ng-container>

    <!-- Footer -->
    <ng-container matColumnDef="footer">
        <td mat-footer-cell *matFooterCellDef colspan="4" class="table-item-counter">
            Celkem kurzů: {{courses.length}}
        </td>
    </ng-container>
  
    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
    <tr mat-footer-row *matFooterRowDef="['footer']" class="footer-row"></tr>
</table>
