<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_settings_search_searchable_content_general %}
<div class="sw-settings-search__searchable-content-general">
    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_search_searchable_content_general_empty_state %}
    <sw-empty-state
        v-if="isEmpty"
        :title="$tc('sw-settings-search.generalTab.textEmptyStateSearchableContent')"
        :show-description="false"
        :has-action-slot="true"
        :absolute="false"
    >
        <template #icon>
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_search_searchable_content_general_state_image %}
            <img
                :src="assetFilter('administration/static/img/empty-states/settings-empty-state.svg')"
                :alt="$tc('sw-settings-search.generalTab.textEmptyStateSearchableContent')"
            >
            {% endblock %}
        </template>
    </sw-empty-state>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_search_searchable_content_general_grid %}
    <sw-entity-listing
        v-if="!isEmpty"
        ref="swSettingsSearchableContentGrid"
        class="sw-settings-search__searchable-content-list"
        :columns="columns"
        :repository="repository"
        :allow-column-edit="false"
        :full-page="false"
        :show-settings="false"
        :show-selection="false"
        :is-loading="isLoading"
        :items="searchConfigs"
        :skeleton-item-amount="searchConfigs && searchConfigs.length"
        :allow-inline-edit="acl.can('product_search_config.editor')"
        @inline-edit-save="onInlineEditSave"
        @inline-edit-cancel="onInlineEditCancel"
    >
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_searchable_content_general_field %}
        <template #column-field="{ item, isInlineEdit }">
            <template v-if="item._isNew && isInlineEdit">
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_field_editor %}
                <sw-single-select
                    v-model:value="item.field"
                    class="sw-settings-search-field-select"
                    size="small"
                    show-clearable-button
                    :options="fieldConfigs"
                    @update:value="onSelectField(item)"
                />
                {% endblock %}
            </template>
            <template v-else>
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_field_label %}
                {{ getMatchingFields(item.field) }}
                {% endblock %}
            </template>
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_searchable_content_general_ranking %}
        <template #column-ranking="{ item, isInlineEdit }">
            <template v-if="isInlineEdit">
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_ranking_editor %}
                <sw-number-field
                    v-model:value="item.ranking"
                    number-type="int"
                    size="small"
                />
                {% endblock %}
            </template>
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_searchable_content_general_searchable %}
        <template #column-searchable="{ item, isInlineEdit }">
            <template v-if="isInlineEdit">
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_searchable_editor %}
                <sw-checkbox-field
                    v-model:value="item.searchable"
                />
                {% endblock %}
            </template>

            <template v-else>
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_searchable_label %}
                <sw-data-grid-column-boolean v-model:value="item.searchable" />
                {% endblock %}
            </template>
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_searchable_content_general_tokenize %}
        <template #column-tokenize="{ item, isInlineEdit }">
            <template v-if="isInlineEdit">
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_tokenize_editor %}
                <sw-checkbox-field
                    v-model:value="item.tokenize"
                />
                {% endblock %}
            </template>

            <template v-else>
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_search_searchable_content_general_tokenize_label %}
                <sw-data-grid-column-boolean v-model:value="item.tokenize" />
                {% endblock %}
            </template>
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_searchable_content_general_columns_actions %}
        <template #actions="{ item }">
            <sw-context-menu-item
                class="sw-settings-search__searchable-content-list-action sw-settings-search__searchable-content-list-edit"
                :disabled="!acl.can('product_search_config.editor')"
                @click="onInlineEditItem(item)"
            >
                {{ $tc('global.default.edit') }}
            </sw-context-menu-item>

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_search_searchable_content_general_columns_actions_edit %}
            <sw-context-menu-item
                class="sw-settings-search__searchable-content-list-action sw-settings-search__searchable-content-list-reset"
                :disabled="!acl.can('product_search_config.editor')"
                @click="onResetRanking(item)"
            >
                {{ $tc('sw-settings-search.generalTab.list.textResetRanking') }}
            </sw-context-menu-item>
            {% endblock %}
        </template>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_search_searchable_content_general_pagination %}
        <template #pagination>
            <sw-pagination
                :page="page"
                :limit="limit"
                :total="total"
                auto-hide
            />
        </template>
        {% endblock %}
    </sw-entity-listing>
    {% endblock %}
</div>
{% endblock %}
