<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_category_detail_products %}
<div class="sw-category-detail-products">

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_category_detail_product_assignment %}
    <sw-many-to-many-assignment-card
        v-if="category.type !== 'folder'"
        :title="$tc('sw-category.base.products.productAssignmentHeadline')"
        :entity-collection="category.products"
        :columns="productColumns"
        :is-loading="isLoading"
        :disabled="!acl.can('category.editor')"
        :local-mode="category.isNew()"
        :criteria="productCriteria"
        :select-label="$tc('sw-category.base.products.productAssignmentLabel')"
        :placeholder="$tc('sw-category.base.products.productAssignmentPlaceholder')"
        @paginate="onPaginateManualProductAssignment"
    >

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_category_detail_product_assignment_type_select %}
        <template #prepend-select>

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_category_detail_product_assignment_type_select_field %}
            <sw-single-select
                v-model:value="category.productAssignmentType"
                class="sw-category-detail-products__product-assignment-type-select"
                :label="$tc('sw-category.base.products.productAssignmentTypeLabel')"
                :error="categoryProductAssignmentTypeError"
                :options="productAssignmentTypes"
                :disabled="!acl.can('category.editor')"
                required
                show-clearable-button
            />
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_category_detail_product_assignment_manual_alert %}
            <sw-alert
                v-if="category.productAssignmentType === 'product_stream' && manualAssignedProductsCount > 0"
                variant="info"
            >
                {{ $tc('sw-category.base.products.alertManualAssignedProductsOnAssignmentTypeStream') }}
            </sw-alert>
            {% endblock %}
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_category_detail_product_assignment_stream_select %}
        <template
            v-if="category.productAssignmentType === 'product_stream'"
            #select
        >

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_category_detail_product_assignment_stream_select_field %}
            <sw-entity-single-select
                v-model:value="category.productStreamId"
                class="sw-category-detail-products__product-stream-select"
                entity="product_stream"
                show-clearable-button
                :disabled="!acl.can('category.editor')"
                :label="$tc('sw-category.base.products.productAssignmentTypeStreamLabel')"
                :help-text="dynamicProductGroupHelpText"
                :placeholder="$tc('sw-category.base.products.productAssignmentTypeStreamPlaceholder')"
                :error="productStreamInvalidError || categoryProductStreamIdError"
            />
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_category_detail_product_assignment_stream_preview_link %}
            <div class="sw-category-detail-products__product-stream-preview-link">
                <router-link
                    v-if="category.productStreamId"
                    :to="{ name: 'sw.product.stream.detail', params: { id: category.productStreamId } }"
                >
                    {{ $tc('sw-category.base.products.dynamicProductGroupDetailLinkText') }}
                    <sw-icon
                        name="regular-long-arrow-right"
                        small
                    />
                </router-link>
            </div>
            {% endblock %}
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_category_detail_product_assignment_stream_preview_grid %}
        <template
            v-if="category.productAssignmentType === 'product_stream'"
            #data-grid
        >
            <sw-product-stream-grid-preview
                :filters="productStreamFilter"
                :columns="productColumns"
            />
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_category_detail_product_assignment_column_name %}
        <template #[nameColumn]="{ item, column }">
            <router-link
                :to="{ name: column.routerLink, params: { id: item.id } }"
            >
                <sw-product-variant-info :variations="item.variation">
                    {{ item.name || item.translated.name }}
                </sw-product-variant-info>
            </router-link>
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_category_detail_product_assignment_column_manufacturer %}
        <template #[manufacturerColumn]="{ item, column }">
            <router-link
                v-if="getManufacturer(item)"
                :to="{ name: column.routerLink, params: { id: item.manufacturerId } }"
            >
                {{ getManufacturer(item).name || getManufacturer(item).translated.name }}
            </router-link>
            <span v-else></span>
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_category_detail_product_assignment_empty_state %}
        <template #empty-state>
            <sw-empty-state
                :title="$tc('sw-category.base.products.productAssignmentEmptyStateDescription')"
                :subline="''"
                auto-height
            >
                <template #icon>
                    <img
                        :src="assetFilter('/administration/static/img/empty-states/products-empty-state.svg')"
                        :alt="$tc('sw-category.base.products.productAssignmentEmptyStateDescription')"
                    >
                </template>
            </sw-empty-state>
        </template>
        {% endblock %}

    </sw-many-to-many-assignment-card>
    {% endblock %}

</div>
{% endblock %}
