<vdr-action-bar>
    <vdr-ab-right>
        <a class="btn btn-primary" [routerLink]="['./create']">
            <clr-icon shape="plus"></clr-icon>
            {{ 'settings.create-new-role' | translate }}
        </a>
    </vdr-ab-right>
</vdr-action-bar>

<vdr-data-table
    [items]="items$ | async"
    [itemsPerPage]="itemsPerPage$ | async"
    [totalItems]="totalItems$ | async"
    [currentPage]="currentPage$ | async"
    (pageChange)="setPageNumber($event)"
    (itemsPerPageChange)="setItemsPerPage($event)"
>
    <vdr-dt-column>{{ 'common.ID' | translate }}</vdr-dt-column>
    <vdr-dt-column>{{ 'common.code' | translate }}</vdr-dt-column>
    <vdr-dt-column>{{ 'common.description' | translate }}</vdr-dt-column>
    <vdr-dt-column>{{ 'settings.permissions' | translate }}</vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <ng-template let-role="item">
        <td class="left align-middle">{{ role.id }}</td>
        <td class="left align-middle">{{ role.code }}</td>
        <td class="left align-middle">{{ role.description }}</td>
        <td class="left align-middle">
            <ng-container *ngIf="!isDefaultRole(role)">
                <vdr-chip *ngFor="let permission of role.permissions">{{ permission }}</vdr-chip>
            </ng-container>
        </td>
        <td class="right align-middle">
            <vdr-table-row-action
                [disabled]="isDefaultRole(role)"
                iconShape="edit"
                [label]="'common.edit' | translate"
                [linkTo]="['./', role.id]"
            ></vdr-table-row-action>
        </td>
    </ng-template>
</vdr-data-table>
