{% block sw_promotion_list %}
    <sw-page class="sw-promotion-list">

        {% block sw_order_list_search_bar %}
            <template slot="search-bar">
                <sw-search-bar initialSearchType="promotion"
                               :placeholder="$tc('sw-promotion.list.placeholderSearchBar')"
                               :initialSearch="term"
                               @search="onSearch">
                </sw-search-bar>
            </template>
        {% endblock %}

        {% block sw_promotion_list_smart_bar_header %}
            <template slot="smart-bar-header">
                {% block sw_promotion_list_smart_bar_header_title %}
                    <h2>
                        {% block sw_promotion_list_smart_bar_header_title_text %}
                            {{ $tc('sw-promotion.list.textTitle') }}
                        {% endblock %}

                        {% block sw_promotion_list_smart_bar_header_amount %}
                            <span v-if="!isLoading" class="sw-page__smart-bar-amount">
                            ({{ total }})
                            </span>
                        {% endblock %}
                    </h2>
                {% endblock %}
            </template>
        {% endblock %}

        {% block sw_promotion_list_smart_bar_actions %}
            <template slot="smart-bar-actions">
                {% block sw_promotion_list_smart_bar_actions_add %}
                    <sw-button :routerLink="{ name: 'sw.promotion.create' }" variant="primary">
                        {{ $tc('sw-promotion.list.buttonAddPromotion') }}
                    </sw-button>
                {% endblock %}
            </template>
        {% endblock %}

        {% block sw_promotion_list_language_switch %}
            <sw-language-switch slot="language-switch" @on-change="onChangeLanguage"></sw-language-switch>
        {% endblock %}

        <template slot="content">
            {% block sw_promotion_list_content %}
                <div class="sw-promotion-list__content">
                    {% block sw_promotion_list_grid %}
                        <sw-entity-listing :repository="promotionRepository"
                                           :columns="promotionColumns"
                                           :items="promotions"
                                           detailRoute="sw.promotion.detail"
                                           :isLoading="isLoading"
                                           allowInlineEdit
                                           allowColumnEdit
                                           fullPage>

                            {% block sw_promotion_list_grid_columns %}
                                {% block sw_promotion_list_grid_columns_active %}
                                    <template #column-active="{ item }">
                                        <sw-icon v-if="item.active" name="small-default-checkmark-line-medium" small class="is--active"></sw-icon>
                                        <sw-icon v-else name="small-default-x-line-medium" small class="is--inactive"></sw-icon>
                                    </template>
                                {% endblock %}

                                {% block sw_promotion_list_grid_columns_valid_from %}
                                    <template #column-validFrom="{ item }">
                                        {{ item.validFrom| date({ hour: '2-digit', minute: '2-digit' }) }}
                                    </template>
                                {% endblock %}

                                {% block sw_promotion_list_grid_columns_valid_until %}
                                    <template #column-validUntil="{ item }">
                                        {{ item.validUntil | date({ hour: '2-digit', minute: '2-digit' }) }}
                                    </template>
                                {% endblock %}
                            {% endblock %}

                            <template #delete-action="{ item, showDelete }">
                                <sw-context-menu-item @click="showDelete(item.id)" :disabled="item.hasOrders" variant="danger">
                                    {{ $tc('global.entity-components.deleteAction') }}
                                </sw-context-menu-item>
                            </template>

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

                    {% block sw_promotion_list_empty_state %}
                        <sw-empty-state v-if="!isLoading && !total" :title="$tc('sw-promotion.list.messageEmpty')"></sw-empty-state>
                    {% endblock %}
                </div>
            {% endblock %}
        </template>

        {% block sw_promotion_list_sidebar %}
            <sw-sidebar slot="sidebar">
                {% block sw_promotion_list_sidebar_refresh %}
                    <sw-sidebar-item
                            icon="default-arrow-360-left"
                            :title="$tc('sw-promotion.list.titleSidebarItemRefresh')"
                            @click="onRefresh">
                    </sw-sidebar-item>
                {% endblock %}
            </sw-sidebar>
        {% endblock %}
    </sw-page>
{% endblock %}
