{% load i18n %}
{% load pagination %}


<div class="paginator">
  <div class="row">
  {% if page.has_previous or page.has_next %}
  <nav aria-label="Page navigation" class="d-flex justify-content-center">
    <ul class="pagination">
    {% if page.has_previous %}
        <li class="page-item">
            <a href="?{% add_to_query_string page_key page.previous_page_number %}" class="page-link">
                &larr; {{ label_previous }}
            </a>
        </li>
    {% else %}
        <li class="page-item disabled"><a href="#" class="page-link">&larr; {{ label_previous }}</a></li>
    {% endif %}

    {% for pagenum in page.paginator.page_range_ellipsis %}
        {% if pagenum == page.number %}
            <li class="page-item active"><span class="page-link" aria-label="Current Page, Page {{ pagenum }}" aria-current="true">{{ pagenum }}</span></li>
        {% elif pagenum == "..." %}
            <li class="page-item"><a href="#" class="jump-to-page active page-link">...</a></li>
        {% else %}
            <li class="page-item"><a href="?{% add_to_query_string page_key pagenum %}" class="page-link" aria-label="Goto Page {{ pagenum }}">{{ pagenum }}</a></li>
        {% endif %}
    {% endfor %}

    {% if page.has_next %}
        <li class="page-item">
            <a href="?{% add_to_query_string page_key page.next_page_number %}" class="page-link">
                {{ label_next }} &rarr;
            </a>
        </li>
    {% else %}
        <li class="page-item disabled" class="page-item"><a href="#" class="page-link">{{ label_next }} &rarr;</a></li>
    {% endif %}
</ul>
</nav>
</div>
<div class="row">
<form class="form-inline jump-to-page" action="" method="get">
    <label>
        {% trans 'Jump to page:' %}
    </label>
        <select name="{{ page_key }}">
        {% for pagenum in page.paginator.page_range %}
            <option value="{{ pagenum }}"
                {% if page.number == pagenum %}selected{% endif %}>
                {{ pagenum }}
            </option>
        {% endfor %}
        </select>

    {% for key, value in request.GET.items %}
        {% if key != page_key %}
            <input type="hidden" name="{{ key }}" value="{{ value }}" />
        {% endif %}
    {% endfor %}
</form>
{% endif %}
<form class="" action="" method="get">
    <label>{% trans 'Results per page:' %}</label>
    <select name="{{ count_key }}">
        {% for count in per_page_options %}
            <option value="{{ count }}"
                {% if page.paginator.per_page == count %}
                selected="selected"
                {% endif %}
                >{{ count }}
            </option>
        {% endfor %}
    </select>
    {% for key, value in request.GET.items %}
        {% if key != count_key %}
            <input type="hidden" name="{{ key }}" value="{{ value }}" />
        {% endif %}
    {% endfor %}
    <input type="submit" class="btn btn-primary btn-sm" value="{% trans 'Update' %}" />
</form>
</div>
</div>
