{#
 # Display dropdown for page size
 #
 # Parameters:
 #   admin_list: AdminList object
 #   route:      Route to use, else current route is used
 #   options:    Options for page sizes
 #   text:       Text for options, default is from translation
 #}

{% if route is not defined %}{% set route = app.request.attributes.get('_route') %}{% endif %}
{% set current_size = admin_list.getPageSize() %}
{% set base_params = admin_list.getParams() %}
{% if options is not defined %}
    {% set options = [ 25, 50, 100, 250, 500, 1000 ] %}
{% endif %}
{% if text is not defined %}
    {% set text = 'admin_list.page_size'|trans({}, 'backend') %}
{% endif %}

<div class="adminlist-page-size">
    <div class="dropdown dropup">
        <a href="javascript:;" class="btn btn-default btn-sm" data-toggle="dropdown">{{ text|replace({ '%size%' : current_size }) }}<i class="icon-arrow-down"></i></a>
        <div class="dropdown-wrapper">
            <ul class="dropdown-menu dropdown-menu-left">
                {% for option in options %}
                    <li>
                        <a href="{{ path(route, base_params|merge({ page: 0, pageSize : option }) ) }}">{{ text|replace({ '%size%' : option }) }}</a>
                    </li>
                {% endfor %}
            </ul>
        </div>
    </div>
</div>