<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_settings_list %}
<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_settings_document_index %}
<sw-page class="sw-settings-document-list">

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_document_list_search_bar %}
    <template #search-bar>
        <sw-search-bar
            :placeholder="$tc('sw-settings-document.general.placeholderSearchBar')"
            :search-type="$tc('sw-settings-document.general.mainMenuItemGeneral')"
            @search="onSearch"
        />
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_document_list_smart_bar_header %}
    <template #smart-bar-header>
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_document_list_smart_bar_header_title %}
        <h2>
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_document_list_smart_bar_header_title_text %}
            {{ $tc('sw-settings.index.title') }}
            <sw-icon
                name="regular-chevron-right-xs"
                small
            /> {{ $tc('sw-settings-document.list.textHeadline') }}
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_document_list_smart_bar_header_amount %}
            <span
                v-if="!isLoading"
                class="sw-page__smart-bar-amount"
            >
                ({{ total }})
            </span>
            {% endblock %}
        </h2>
        {% endblock %}
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_document_list_smart_bar_actions %}
    <template #smart-bar-actions>
        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_document_list_smart_bar_actions_add %}
        <sw-button
            v-tooltip.bottom="{
                message: $tc('sw-privileges.tooltip.warning'),
                disabled: acl.can('document.creator'),
                showOnDisabledElements: true
            }"
            :router-link="{ name: 'sw.settings.document.create' }"
            :disabled="!acl.can('document.creator') || undefined"
            class="sw-settings-document-list__add-document"
            variant="primary"
        >
            {{ $tc('sw-settings-document.list.buttonAddDocument') }}
        </sw-button>
        {% endblock %}
    </template>
    {% endblock %}

    <template #language-switch>
        <sw-language-switch
            @on-change="onChangeLanguage"
        />
    </template>

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_document_list_content %}
    <template #content>
        <sw-card-view>
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_document_list_content_card %}
            <sw-card
                :is-loading="isLoading"
                position-identifier="sw-settings-document-list-content"
            >
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_document_list_grid %}
                <template #grid>
                    <sw-grid
                        class="sw-settings-document-list-grid"
                        :items="items"
                        :selectable="false"
                        table
                    >
                        <template
                            #columns="{ item }"
                        >
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_product_list_grid_columns %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_document_list_columns_name %}
                            <sw-grid-column
                                class="sw-document-list__column-name"
                                flex="minmax(100px, 1fr)"
                                :label="$tc('sw-settings-document.list.columnName')"
                            >

                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                {% block sw_settings_document_list_columns_name_link %}
                                <router-link
                                    :title="$tc('sw-settings-document.list.contextMenuEdit')"
                                    :to="{ name: 'sw.settings.document.detail', params: { id: item.id } }"
                                >
                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_settings_document_list_columns_name_link_inner %}
                                    {{ item.name }}
                                    {% endblock %}
                                </router-link>
                                {% endblock %}
                            </sw-grid-column>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_document_list_columns_type %}
                            <sw-grid-column
                                v-if="item.documentType.translated"
                                class="sw-document-list__column-type"
                                flex="minmax(100px, 1fr)"
                                :label="$tc('sw-settings-document.list.columnType')"
                            >
                                {{ item.documentType.translated.name }}
                            </sw-grid-column>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_document_list_columns_assignment %}
                            <sw-grid-column
                                flex="minmax(100px, 1fr)"
                                :label="$tc('sw-settings-document.list.columnAssignment')"
                            >
                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                {% block sw_settings_document_list_columns_assignment_label %}
                                <div
                                    v-if="item.global"
                                    class="sw-list sw-document-list__label-wrapper"
                                >
                                    <sw-label size="medium">
                                        {{ $tc('sw-settings-document.list.global') }}
                                    </sw-label>
                                </div>
                                <ul
                                    v-if="!item.global"
                                    class="sw-list sw-document-list__label-wrapper"
                                >
                                    <li
                                        v-for="(salesChannel, index) in item.salesChannels"
                                        :key="index"
                                    >
                                        <sw-label
                                            v-if="salesChannel.salesChannel && salesChannel.salesChannel.translated"
                                            size="medium"
                                        >
                                            {{ salesChannel.salesChannel.translated.name }}
                                        </sw-label>
                                    </li>
                                </ul>
                                {% endblock %}
                            </sw-grid-column>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_document_list_columns_actions %}
                            <sw-grid-column
                                flex="minmax(70px, 70px)"
                                align="center"
                                label=""
                            >
                                <sw-context-button>

                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_settings_document_list_columns_actions_edit %}
                                    <sw-context-menu-item
                                        class="sw-document-list__edit-action"
                                        :disabled="!acl.can('document.editor')"
                                        :router-link="{ name: 'sw.settings.document.detail', params: { id: item.id } }"
                                    >
                                        {{ $tc('sw-settings-document.list.contextMenuEdit') }}
                                    </sw-context-menu-item>
                                    {% endblock %}

                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_settings_document_list_columns_actions_delete %}
                                    <sw-context-menu-item
                                        variant="danger"
                                        class="sw-document-list__delete-action"
                                        :disabled="!acl.can('document.deleter')"
                                        @click="onDelete(item.id)"
                                    >
                                        {{ $tc('sw-settings-document.list.buttonDelete') }}
                                    </sw-context-menu-item>
                                    {% endblock %}
                                </sw-context-button>
                            </sw-grid-column>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_document_list_delete_modal %}
                            <sw-modal
                                v-if="showDeleteModal === item.id"
                                :title="$tc('global.default.warning')"
                                variant="small"
                                @modal-close="onCloseDeleteModal"
                            >
                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                {% block sw_settings_document_list_delete_modal_confirm_text %}
                                <p>
                                    {{ $tc('sw-settings-document.list.textDeleteConfirm', 0, { name: item.name }) }}
                                </p>
                                {% endblock %}

                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                {% block sw_settings_document_list_delete_modal_footer %}
                                <template #modal-footer>
                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_settings_document_list_delete_modal_actions_cancel %}
                                    <sw-button
                                        size="small"
                                        @click="onCloseDeleteModal"
                                    >
                                        {{ $tc('global.default.cancel') }}
                                    </sw-button>
                                    {% endblock %}

                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_settings_document_list_delete_modal_actions_delete %}
                                    <sw-button
                                        variant="danger"
                                        size="small"
                                        @click="onConfirmDelete(item.id)"
                                    >
                                        {{ $tc('sw-settings-document.list.buttonDelete') }}
                                    </sw-button>
                                    {% endblock %}
                                </template>
                                {% endblock %}
                            </sw-modal>
                            {% endblock %}
                            {% endblock %}
                        </template>

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_document_list_grid_pagination %}
                        <template #pagination>
                            <sw-pagination
                                :page="page"
                                :limit="limit"
                                :total="total"
                                :total-visible="7"
                                @page-change="onPageChange"
                            />
                        </template>
                        {% endblock %}
                    </sw-grid>
                </template>
                {% endblock %}
            </sw-card>
            {% endblock %}
        </sw-card-view>
    </template>
    {% endblock %}
</sw-page>
    {% endblock %}
{% endblock %}
