<vdr-page-block>
    <vdr-action-bar>
        <vdr-ab-left> </vdr-ab-left>
        <vdr-ab-right>
            <vdr-action-bar-items locationId="administrator-list" />
            <a
                class="btn btn-primary"
                *vdrIfPermissions="['CreateAdministrator']"
                [routerLink]="['./', 'create']"
            >
                <clr-icon shape="plus"></clr-icon>
                {{ 'admin.create-new-administrator' | translate }}
            </a>
            <vdr-action-bar-dropdown-menu locationId="administrator-list" />
        </vdr-ab-right>
    </vdr-action-bar>
</vdr-page-block>
<vdr-data-table-2
    class="mt-2"
    id="administrator-list"
    [items]="items$ | async"
    [itemsPerPage]="itemsPerPage$ | async"
    [totalItems]="totalItems$ | async"
    [currentPage]="currentPage$ | async"
    [filters]="filters"
    (pageChange)="setPageNumber($event)"
    (itemsPerPageChange)="setItemsPerPage($event)"
>
    <vdr-bulk-action-menu
        locationId="administrator-list"
        [hostComponent]="this"
        [selectionManager]="selectionManager"
    />
    <vdr-dt2-search
        [searchTermControl]="searchTermControl"
        [searchTermPlaceholder]="'catalog.filter-by-name' | translate"
    />
    <vdr-dt2-column [heading]="'common.id' | translate" id="id" [hiddenByDefault]="true">
        <ng-template let-administrator="item">
            {{ administrator.id }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column
        [heading]="'common.created-at' | translate" id="created-at"
        [hiddenByDefault]="true"
        [sort]="sorts.get('createdAt')"
    >
        <ng-template let-administrator="item">
            {{ administrator.createdAt | localeDate : 'short' }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column
        [heading]="'common.updated-at' | translate" id="updated-at"
        [hiddenByDefault]="true"
        [sort]="sorts.get('updatedAt')"
    >
        <ng-template let-administrator="item">
            {{ administrator.updatedAt | localeDate : 'short' }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'common.name' | translate" id="name" [optional]="false" [sort]="sorts.get('lastName')">
        <ng-template let-administrator="item">
            <a class="button-ghost" [routerLink]="['./', administrator.id]"
                ><span>{{ administrator.firstName }} {{ administrator.lastName }}</span>
                <clr-icon shape="arrow right"></clr-icon>
            </a>
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'settings.email-address' | translate" id="email-address" [sort]="sorts.get('emailAddress')">
        <ng-template let-administrator="item">
            {{ administrator.emailAddress }}
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-column [heading]="'settings.roles' | translate" id="roles">
        <ng-template let-administrator="item">
            <vdr-chip *ngFor="let role of administrator.user.roles">{{ role.description }}</vdr-chip>
        </ng-template>
    </vdr-dt2-column>
    <vdr-dt2-custom-field-column
        *ngFor="let customField of customFields"
        [customField]="customField"
        [sorts]="sorts"
    />
</vdr-data-table-2>
