<vdr-action-bar>
    <vdr-ab-right>
        <vdr-action-bar-items locationId="payment-method-list"></vdr-action-bar-items>
        <a class="btn btn-primary" [routerLink]="['./create']" *vdrIfPermissions="['CreateSettings', 'CreatePaymentMethod']">
            <clr-icon shape="plus"></clr-icon>
            {{ 'settings.create-new-payment-method' | 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.code' | translate }}</vdr-dt-column>
    <vdr-dt-column>{{ 'common.enabled' | translate }}</vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <ng-template let-paymentMethod="item">
        <td class="left align-middle">{{ paymentMethod.code }}</td>
        <td class="left align-middle">{{ paymentMethod.enabled }}</td>
        <td class="right align-middle">
            <vdr-table-row-action
                iconShape="edit"
                [label]="'common.edit' | translate"
                [linkTo]="['./', paymentMethod.id]"
            ></vdr-table-row-action>
        </td>
        <td class="right align-middle">
            <vdr-dropdown>
                <button type="button" class="btn btn-link btn-sm" vdrDropdownTrigger>
                    {{ 'common.actions' | translate }}
                    <clr-icon shape="caret down"></clr-icon>
                </button>
                <vdr-dropdown-menu vdrPosition="bottom-right">
                    <button
                        type="button"
                        class="delete-button"
                        (click)="deletePaymentMethod(paymentMethod.id)"
                        [disabled]="!(['DeleteSettings', 'DeletePaymentMethod'] | hasPermission)"
                        vdrDropdownItem
                    >
                        <clr-icon shape="trash" class="is-danger"></clr-icon>
                        {{ 'common.delete' | translate }}
                    </button>
                </vdr-dropdown-menu>
            </vdr-dropdown>
        </td>
    </ng-template>
</vdr-data-table>
