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

{% set pages = admin_list.getPageNumbers() %}
{% set current_page = admin_list.getCurrentPage() %}
{% set base_params = admin_list.getParams() %}
{% set order_direction = admin_list.getOrderDir() %}
{% set order_field = admin_list.getOrderField() %}

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

{% if pages|length > 1 %}
    <ul class="{{class}}">
        {% for page in pages %}
            <li class="{% if current_page == page %}active{% endif %}">
                <a href="{{ path(route, base_params|merge({ page: page, orderDir : order_direction, orderBy : order_field }) ) }}">
                    {% if loop.first and page > 0 %}&hellip;{% endif %}{{ page+1 }}{% if loop.last %}&hellip;{% endif %}
                </a>
            </li>        
        {% endfor %}
    </ul>
{% endif %}
