{#
 # Display Item list using AdminList object
 #
 # Parameters:
 #   admin_list: AdminList object
 #   class:      Class for table, 'table' if not set
 #   route:      Route to use, else current route is used
 #
 #}

{% set items = admin_list.getPageIndex() %}
{% set columns = admin_list.getColumns() %}

{% if route is not defined %}{% set route = app.request.attributes.get('_route') %}{% endif %}
{% if class is not defined %}{% set class = 'table' %}{% endif %}

<div class="table-responsive">
    <table class="{{ class }}">
        <colgroup>
            {% for column_decorator in columns %}
                <col {% if column_decorator.width is not empty %}width="{{ column_decorator.width }}"{% endif %} {% if column_decorator.span is not empty %}span="{{ column_decorator.span }}"{% endif %} />
            {% endfor %}
        </colgroup>
        <thead>
            <tr>
                {% for column_decorator in columns %}
                    {% include column_decorator.column.HeaderTemplate with { column : column_decorator.column }  %}
                {% endfor %}
            </tr>
        </thead>
        <tbody>
            {% for item in items %}
                <tr class="{{ admin_list.getRowClass(item) }}">
                    {% for column_decorator in columns %}
                        {% include column_decorator.column.ItemTemplate with { column : column_decorator.column } %}
                    {% endfor %}
                </tr>
            {% endfor %}
        </tbody>
        {% if admin_list.hasFooters %}
            <tfoot>
                <tr>
                    {% for column_decorator in columns %}
                        {% if column_decorator.column.FooterTemplate is not null %}
                            {% include column_decorator.column.FooterTemplate with { column : column_decorator.column }  %}
                        {% else %}
                            <td>&nbsp;</td>
                        {% endif %}
                    {% endfor %}
                </tr>
            </tfoot>
        {% endif %}
    </table>
</div>