{% from "_custom_select.html" import custom_select %} {# Minimal bar: LEFT total count | MIDDLE pager (same control pattern as Commit History modal) | RIGHT per-page picker. Always shown. #} {% macro render_pagination(current_page, total_pages, limit, endpoint, extra_params={}, total_count=none, item_noun='items') %} {% set is_unlimited = (limit is none) or (limit == 'unlimited') %} {% set lim_q = 'unlimited' if is_unlimited else limit %} {% set eff_pages = total_pages if total_pages > 0 else 1 %} {% set pagination_options = [ {"value": url_for(endpoint, page=1, limit='5', **extra_params), "label": "5"}, {"value": url_for(endpoint, page=1, limit='10', **extra_params), "label": "10"}, {"value": url_for(endpoint, page=1, limit='25', **extra_params), "label": "25"}, {"value": url_for(endpoint, page=1, limit='50', **extra_params), "label": "50"}, {"value": url_for(endpoint, page=1, limit='unlimited', **extra_params), "label": "All"} ] %} {% set _limit = 'unlimited' if is_unlimited else (limit|string) %} {% set pagination_selected_url = url_for(endpoint, page=1, limit=_limit, **extra_params) %} {% set pagination_selected_label = "All" if is_unlimited else (limit|string) %}
{# Left: total #}

Total {{ total_count if total_count is not none else '—' }} {{ item_noun }}

{# Center: first | prev | current | next | last (Commit History modal style) #}
{% if not is_unlimited %} {# First #} {% if current_page > 1 %} {% else %} {% endif %} {# Prev #} {% if current_page > 1 %} {% else %} {% endif %} {# Current page #}
{{ current_page }}
{# Next #} {% if current_page < eff_pages %} {% else %} {% endif %} {# Last #} {% if current_page < eff_pages %} {% else %} {% endif %} {% else %} {# Unlimited: show static single-page control #}
1
{% endif %}
{# Right: per page (compact label-only trigger, no chevron — opens modal picker) #}
{{ custom_select(id="pagination-limit", options=pagination_options, selected_value=pagination_selected_url, selected_label=pagination_selected_label, mode="navigate", class="", picker_title="Items per page", show_chevron=false, compact=true) }}
{% endmacro %}