<vdr-action-bar>
    <vdr-ab-right>
        <a class="btn btn-primary" [routerLink]="['./create']">
            <clr-icon shape="plus"></clr-icon>
            {{ 'catalog.create-new-facet' | 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.name' | translate }}</vdr-dt-column>
    <vdr-dt-column [expand]="true">{{ 'catalog.values' | translate }}</vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <ng-template let-facet="item">
        <td class="left align-middle">{{ facet.code }}</td>
        <td class="left align-middle">{{ facet.name }}</td>
        <td class="left align-middle">
            <vdr-facet-value-chip
                *ngFor="let value of facet.values"
                [facetValue]="value"
                [removable]="false"
                [displayFacetName]="false"
            ></vdr-facet-value-chip>
        </td>
        <td class="right align-middle">
            <vdr-table-row-action
                iconShape="edit"
                [label]="'common.edit' | translate"
                [linkTo]="['./', facet.id]"
            ></vdr-table-row-action>
        </td>
        <td class="right align-middle">
            <clr-dropdown>
                <button type="button" class="btn btn-link btn-sm" clrDropdownTrigger>
                    {{ 'common.actions' | translate }}
                    <clr-icon shape="caret down"></clr-icon>
                </button>
                <clr-dropdown-menu *clrIfOpen clrPosition="bottom-right">
                    <button
                        type="button"
                        class="delete-button"
                        (click)="deleteFacet(facet.id)"
                        clrDropdownItem
                    >
                        {{ 'common.delete' | translate }}
                    </button>
                </clr-dropdown-menu>
            </clr-dropdown>
        </td>
    </ng-template>
</vdr-data-table>
