<!-- 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_number_range_index %}
<sw-page class="sw-settings-number-range-list">

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

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

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_number_range_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_number_range_list_language_switch %}
    <template #language-switch>
        <sw-language-switch @on-change="onChangeLanguage" />
    </template>
    {% endblock %}

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

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_number_range_list_content %}
    <template #content>
        <sw-card-view>
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_number_range_list_content_card %}
            <sw-card
                v-if="isLoading || numberRange"
                position-identifier="sw-settings-number-range-list-content"
            >
                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_settings_number_range_list_grid %}
                <template #grid>
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_settings_number_range_list_grid_inner %}
                    <sw-entity-listing
                        ref="swSettingsNumberRangeGrid"
                        class="sw-settings-number-range-list-grid"
                        :items="numberRange"
                        :columns="getNumberRangeColumns()"
                        :repository="numberRangeRepository"
                        :disable-data-fetching="true"
                        :sort-by="sortBy"
                        :sort-direction="sortDirection"
                        :full-page="false"
                        detail-route="sw.settings.number.range.detail"
                        :show-selection="false"
                        :is-loading="isLoading"
                        :allow-edit="acl.can('number_ranges.editor') || undefined"
                        :allow-inline-edit="acl.can('number_ranges.editor') || undefined"
                        :allow-delete="acl.can('number_ranges.deleter') || undefined"
                        :allow-view="acl.can('number_ranges.viewer') || undefined"
                        @page-change="onPageChange"
                        @column-sort="onSortColumn"
                    >
                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_number_range_list_grid_columns_name %}
                        <template #column-global="{ item }">
                            <sw-label
                                v-if="item.type.global || item.global"
                                class="sw-settings-number-range-list__columns-assignment-tag"
                                size="medium"
                            >
                                {{ $tc('sw-settings-number-range.list.global') }}
                            </sw-label>

                            <template v-if="!item.type.global && !item.global">
                                <sw-label
                                    v-for="numberRangeSalesChannel in item.numberRangeSalesChannels"
                                    :key="numberRangeSalesChannel.id"
                                    class="sw-settings-number-range-list__columns-assignment-tag"
                                    size="medium"
                                >
                                    {{ numberRangeSalesChannel.salesChannel.translated.name }}
                                </sw-label>
                            </template>
                        </template>
                        {% endblock %}

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_number_range_list_grid_columns_actions %}
                        <template #actions="{ item }">
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_number_range_list_grid_columns_actions_edit %}
                            <sw-context-menu-item
                                class="sw-entity-listing__context-menu-edit-action"
                                :disabled="!acl.can('number_ranges.editor') || undefined"
                                :router-link="{ name: 'sw.settings.number.range.detail', params: { id: item.id, edit: 'edit' }}"
                            >
                                {{ $tc('sw-settings-number-range.list.contextMenuEdit') }}
                            </sw-context-menu-item>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_number_range_list_grid_columns_actions_delete %}
                            <sw-context-menu-item
                                class="sw-entity-listing__context-menu-edit-delete"
                                variant="danger"
                                :disabled="!acl.can('number_ranges.deleter') || undefined"
                                @click="onDelete(item.id)"
                            >
                                {{ $tc('sw-settings-number-range.list.contextMenuDelete') }}
                            </sw-context-menu-item>
                            {% endblock %}
                        </template>
                        {% endblock %}

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_number_range_list_grid_action_modals %}
                        <template #action-modals="{ item }">
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_number_range_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_number_range_list_delete_modal_confirm_delete_text %}
                                <p class="sw-settings-number-range-list__confirm-delete-text">
                                    {{ $tc('sw-settings-number-range.list.textDeleteConfirm', 0, { name: item.name }) }}
                                </p>
                                {% endblock %}

                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                {% block sw_settings_number_range_list_delete_modal_footer %}
                                <template #modal-footer>
                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_settings_number_range_list_delete_modal_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_number_range_list_delete_modal_confirm %}
                                    <sw-button
                                        variant="danger"
                                        size="small"
                                        @click="onConfirmDelete(item.id)"
                                    >
                                        {{ $tc('sw-settings-number-range.list.buttonDelete') }}
                                    </sw-button>
                                    {% endblock %}
                                </template>
                                {% endblock %}
                            </sw-modal>
                            {% endblock %}
                        </template>
                        {% endblock %}
                    </sw-entity-listing>
                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_settings_number_ranges_set_list_empty_message %}
                    <sw-empty-state
                        v-if="!isLoading && !total"
                        :title="$tc('sw-settings-number-range.list.messageEmpty')"
                    />
                    {% endblock %}
                    {% endblock %}
                </template>
                {% endblock %}
            </sw-card>
            {% endblock %}
        </sw-card-view>
    </template>
    {% endblock %}
</sw-page>
    {% endblock %}
{% endblock %}
