<!-- 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_language_index %}
<sw-page class="sw-settings-language-list">

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

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_language_list_smart_bar_header %}
    <template #smart-bar-header>

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_language_list_smart_bar_header_title %}
        <h2>

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_smart_bar_header_title_text %}
            {{ $tc('sw-settings.index.title') }}
            <sw-icon
                name="regular-chevron-right-xs"
                small
            /> {{ $tc('sw-settings-language.list.textHeadline') }}
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_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_language_list_smart_bar_actions %}
    <template #smart-bar-actions>

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_settings_language_list_smart_bar_actions_add %}
        <sw-button
            v-tooltip.bottom="{
                message: $tc('sw-privileges.tooltip.warning'),
                disabled: allowCreate,
                showOnDisabledElements: true
            }"
            class="sw-settings-language-list__button-create"
            variant="primary"
            :disabled="!allowCreate || undefined"
            :router-link="{ name: 'sw.settings.language.create' }"
        >
            {{ $tc('sw-settings-language.list.buttonAddLanguage') }}
        </sw-button>
        {% endblock %}

    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_language_list_content %}
    <template #content>
        <sw-entity-listing
            key="language-listing"
            class="sw-settings-language-list-grid"
            detail-route="sw.settings.language.detail"
            :is-loading="isLoading"
            :repository="languageRepository"
            :columns="getColumns"
            :items="languages"
            :sort-by="sortBy"
            :sort-direction="sortDirection"
            :disable-data-fetching="true"
            :allow-view="allowView || undefined"
            :allow-edit="allowEdit || undefined"
            :allow-inline-edit="allowInlineEdit || undefined"
            :allow-delete="allowDelete || undefined"
            @column-sort="onSortColumn"
            @page-change="onPageChange"
        >

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_content %}
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_columns %}
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_column_name %}
            <template #column-name="{ item, column, compact, isInlineEdit }">
                <sw-text-field
                    v-if="isInlineEdit"
                    v-model:value="item.name"
                    :size="compact ? 'small' : 'default'"
                />
                <router-link
                    v-else
                    :title="$tc('sw-settings-language.list.contextMenuEdit')"
                    :to="{ name: 'sw.settings.language.detail', params: { id: item.id } }"
                >
                    {{ item.name }}
                </router-link>
            </template>
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_column_locale %}
            <template #column-locale="{ item, column, compact, isInlineEdit }">
                {{ item.locale.translated.name }}, {{ item.locale.translated.territory }}
            </template>
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_column_id %}
            <template #column-id="{ item, column, compact, isInlineEdit }">
                <sw-icon
                    v-if="isDefault(item.id)"
                    name="regular-checkmark-xs"
                    small
                    class="is--default"
                />
                <div v-else></div>
            </template>
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_column_parent %}
            <template #column-parent="{ item, column, compact, isInlineEdit }">
                {{ getParentName(item) }}
            </template>
            {% endblock %}
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_delete %}
            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_delete_action %}
            <template #delete-action="{ item, showDelete }">
                <sw-context-menu-item
                    v-tooltip.bottom="tooltipDelete(item.id)"
                    class="sw-settings-language-list__delete-action"
                    variant="danger"
                    :disabled="isDefault(item.id) || !allowDelete || undefined"
                    @click="showDelete(item.id)"
                >
                    {{ $tc('global.default.delete') }}
                </sw-context-menu-item>
            </template>
            {% endblock %}

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_content_list_delete_confirm_action %}
            <template #delete-confirm-text="{ item }">
                {{ $tc('sw-settings-language.list.textDeleteConfirm', 1, { name: item.name } ) }}
            </template>
            {% endblock %}
            {% endblock %}
            {% endblock %}

        </sw-entity-listing>
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_settings_language_list_grid_sidebar %}
    <template #sidebar>
        <sw-sidebar :propagate-width="true">

            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
            {% block sw_settings_language_list_grid_sidebar_filter %}
            <sw-sidebar-item
                icon="regular-filter"
                :title="$tc('sw-settings-language.list.titleSidebarFilter')"
            >
                <sw-collapse expand-on-loading>

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_settings_language_list_grid_sidebar_filter_header %}
                    <template #header="{ expanded }">
                        <div class="sw-settings-language-list__collapse-header">

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_language_list_grid_sidebar_filter_header_title %}
                            <h4 class="sw-settings-language-list__collapse-title">
                                {{ $tc('sw-settings-language.list.titleSidebarQuickFilter') }}
                            </h4>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_language_list_grid_sidebar_filter_header_icon %}
                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_language_list_grid_sidebar_filter_header_icon_expanded %}
                            <sw-icon
                                v-if="expanded"
                                class="sw-media-collapse__button"
                                name="regular-chevron-down-xxs"
                                size="12px"
                            />
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_settings_language_list_grid_sidebar_filter_header_icon_not_expanded %}
                            <sw-icon
                                v-else
                                class="sw-media-collapse__button"
                                name="regular-chevron-right-xxs"
                                size="12px"
                            />
                            {% endblock %}
                            {% endblock %}

                        </div>
                    </template>
                    {% endblock %}

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

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_language_list_grid_sidebar_filter_content_root_languages %}
                        <sw-switch-field
                            v-model:value="filterRootLanguages"
                            class="sw-settings-language-list__filterField"
                            :label="$tc('sw-settings-language.list.textFilterRootLanguages')"
                        />
                        {% endblock %}

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_settings_language_list_grid_sidebar_filter_content_inherited_languages %}
                        <sw-switch-field
                            v-model:value="filterInheritedLanguages"
                            class="sw-settings-language-list__filterField"
                            :label="$tc('sw-settings-language.list.textFilterInheritedLanguages')"
                        />
                        {% endblock %}

                    </template>
                    {% endblock %}

                </sw-collapse>
            </sw-sidebar-item>
            {% endblock %}

        </sw-sidebar>
    </template>
    {% endblock %}

</sw-page>
    {% endblock %}
{% endblock %}
