<ng-container *ngVar="(dsoRD$ | async) as itemsRD">
  <ds-pagination
    *ngIf="itemsRD?.payload?.totalElements > 0"
    [paginationOptions]="paginationOptions"
    [sortOptions]="sortOptions"
    [collectionSize]="itemsRD?.payload?.totalElements"
    [hidePagerWhenSinglePage]="true"
    [hideGear]="true">
    <div class="table-responsive mt-2">
      <table id="item-select" class="table table-striped table-hover">
        <thead>
        <tr>
          <th><span class="sr-only">{{'item.select.table.selected' | translate}}</span></th>
          <th *ngIf="!hideCollection" scope="col">{{'item.select.table.collection' | translate}}</th>
          <th scope="col">{{'item.select.table.author' | translate}}</th>
          <th scope="col">{{'item.select.table.title' | translate}}</th>
        </tr>
        </thead>
        <tbody>
        <tr *ngFor="let selectItem of selectItems$ | async">
          <td><input #selectItemBtn [attr.aria-label]="(selectItemBtn.checked ? 'item.select.table.deselect' : 'item.select.table.select') | translate" [disabled]="(selectItem.canSelect$ | async) === false" class="item-checkbox" [ngModel]="selectItem.selected$ | async" (change)="switch(selectItem.dso.id)" type="checkbox" name="{{selectItem.dso.id}}"></td>
          <td *ngIf="!hideCollection">
            <span *ngVar="(selectItem.dso.owningCollection | async)?.payload as collection">
              <a *ngIf="collection" [routerLink]="['/collections', collection?.id]">
                {{ dsoNameService.getName(collection) }}
              </a>
            </span>
          </td>
          <td><span *ngIf="selectItem.dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{selectItem.dso.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
          <td><a [routerLink]="selectItem.route">{{ dsoNameService.getName(selectItem.dso) }}</a></td>
        </tr>
        </tbody>
      </table>
    </div>
  </ds-pagination>
  <div *ngIf="itemsRD?.payload?.totalElements === 0 || itemsRD?.payload?.page?.length === 0" class="alert alert-info w-100" role="alert">
    {{'item.select.empty' | translate}}
  </div>
  <ds-error *ngIf="itemsRD?.hasFailed" message="{{'error.items' | translate}}"></ds-error>
  <ds-themed-loading *ngIf="!itemsRD || itemsRD?.isLoading" message="{{'loading.items' | translate}}"></ds-themed-loading>
  <div *ngVar="(selectedIds$ | async) as selectedIds">
    <button class="btn btn-outline-secondary item-cancel float-left" (click)="onCancel()">{{cancelButton | translate}}</button>
    <button class="btn item-confirm float-right"
            [ngClass]="{'btn-danger': dangerConfirm, 'btn-primary': !dangerConfirm}"
            [dsBtnDisabled]="selectedIds?.length === 0"
            (click)="confirmSelected()">
      {{confirmButton | translate}}
    </button>
  </div>
</ng-container>
