{% trans_default_domain 'admin' %}

<div class="content-block js-property-forms">
    <div class="content-block__header">

        {% block header_left %}
            {% if batch_delete_form %}
                {{ form_start(batch_delete_form, {'attr': {
                    'class':            'js-form js-batch-delete',
                    'data-reload-page': 1,
                    'autocomplete':     'off',
                }}) }}
                {{ form_widget(batch_delete_form, {'attr': {'style': 'display: none;'}}) }}
                <button class="content-block__btn-remove"
                        type="submit"
                        onclick="return confirm('{{ 'crud.action.batch_delete.confirm'|trans|e('js') }}');"
                        style="display: none;">
                    {% trans %}crud.action.batch_delete.submit{% endtrans %}
                </button>
                {{ form_end(batch_delete_form) }}
            {% endif %}
        {% endblock %}

        <div class="content-block__header-right">

            {% block header_right %}
                {% if view.body.rows is not empty %}
                    <div class="content-block__total">
                        {% trans with {'%count%': entity_count} %}common.total_item_count{% endtrans %}
                    </div>
                {% endif %}
                {% if meta.configuration.pagination.enabled and admin_route_exists(meta.entityClass, 'repaginate') %}
                    {{ admin_repaginate_form(meta.entityClass) }}
                {% endif %}
            {% endblock %}

        </div>
    </div>
    <div class="content-block__content">

        {% if view.body.rows is empty %}
            <p class="h2">{% trans %}common.empty_list{% endtrans %}</p>
        {% else %}
            <div class="table" data-simplebar data-simplebar-auto-hide="false">
                <table>
                    <thead>
                        <tr>

                            {% for name, item in view.head.items|filter(item => item.width) %}
                                <th{% for attr_name, attr_value in item.attr %} {{ attr_name }}="{{ attr_value|e('html_attr') }}"{% endfor %}>
                                    {% if 'action_widgets' == name and batch_delete_form %}
                                        <label class="custom-checkbox"
                                               title="{% trans %}crud.action.batch_delete.check_all{% endtrans %}">
                                            <input type="checkbox" class="js-batch-delete-check-all" autocomplete="off">
                                            <span></span>
                                        </label>
                                    {% endif %}
                                    {% if pagination is defined and pagination and item.sortable %}
                                        {{ knp_pagination_sortable(pagination, item.content|trans, item.sortablePropertyPath, [], [], '@DarvinAdmin/sortable.html.twig') }}
                                    {% else %}
                                        {{ item.content|trans }}
                                    {% endif %}
                                </th>
                            {% endfor %}

                        </tr>
                    </thead>
                    <tbody>

                        {% for row in view.body.rows %}

                            {% set attr = row.attr|merge({'class': (row.attr.class|default ~ ' table-row')|trim}) %}

                            <tr{% for attr_name, attr_value in attr %} {{ attr_name }}="{{ attr_value|e('html_attr') }}"{% endfor %}>
                                {% for item in row.items %}
                                    <td{% for attr_name, attr_value in item.attr %} {{ attr_name }}="{{ attr_value|e('html_attr') }}"{% endfor %}>
                                        {{ item.content|trans|raw }}
                                    </td>
                                {% endfor %}
                            </tr>
                        {% endfor %}

                    </tbody>
                </table>
            </div>
        {% endif %}

    </div>

    {% block footer %}
        <div class="content-block__footer">
            <div class="content-block__footer-left">

                {% block footer_left %}{% endblock %}

            </div>
            <div class="content-block__footer-right">

                {% block footer_right %}
                    {% if pagination %}
                        {{ knp_pagination_render(pagination, '@DarvinAdmin/pagination.html.twig') }}
                    {% endif %}
                {% endblock %}

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

</div>
