Plan: Pagination Partial Extraction

On this page

Status

Step Description Status

1

Plan file and nav entry

Not started

2

Create shared pagination partial

Not started

3

Replace pagination blocks in all list templates

Not started

4

Verify all pages render correctly

Not started

5

Documentation, commit, push, MR

Not started

Issues: TBD
Branch: feature/pagination-partial

Context

~18 list templates contain identical pagination HTML (~50 lines each) that renders page numbers, ellipsis, prev/next links, and a total count. The only difference between templates is the base_url (e.g., /cases/, /intake/referrals). This was identified in the UI consistency review and deferred from !42.

Total duplicated lines: ~900 lines across 18 templates.

Design

Shared Partial

File: services/craig-web/templates/_pagination.html

The partial uses variables from the parent template’s scope (Askama includes share scope):

{% if total_pages > 1 %}
<nav class="pagination-bar" aria-label="Pagination">
  {% if page > 1 %}
    <a href="{{ base_url }}?page={{ page - 1 }}{{ extra }}" class="pagination-bar__page" aria-label="Previous page">&laquo;</a>
  {% else %}
    <span class="pagination-bar__page pagination-bar__page--disabled">&laquo;</span>
  {% endif %}
  <!-- ... page numbers, ellipsis, next ... -->
  <span class="pagination-bar__info">{{ total }} total</span>
</nav>
{% endif %}

Required Template Variables

Every template that includes _pagination.html must define:

  • page: u32 — current page number

  • total_pages: u32 — total page count

  • total: i64 — total record count

  • base_url: &str — URL path without query string (e.g., "/cases/")

  • extra: String — additional query params (e.g., "&status=open&search=floyd")

  • win_start: u32 — pagination window start

  • win_end: u32 — pagination window end

All existing list templates already have these fields in their template structs. The only addition is base_url — add as a &'static str or String to each struct.

Templates to Update (18)

Replace inline pagination blocks with {% include "_pagination.html" %}:

<!-- Before: ~50 lines of pagination HTML -->

<!-- After: 1 line -->
{% include "_pagination.html" %}

Templates:

  1. cases/list.html — base_url: "/cases/"

  2. intake/referrals.html"/intake/referrals"

  3. intake/investigations.html / intake/worklist.html"/intake/worklist"

  4. intake/reports.html"/intake/reports"

  5. placement/homes.html"/placement/homes"

  6. placement/placements.html"/placement/list"

  7. placement/matching.html"/placement/matching"

  8. placement/education.html"/placement/education"

  9. placement/health.html"/placement/health"

  10. exchange/partners.html"/exchange/partners"

  11. exchange/agreements.html"/exchange/agreements"

  12. exchange/transactions.html"/exchange/transactions"

  13. exchange/icpc.html"/exchange/icpc"

  14. financial/payments.html"/financial/payments"

  15. financial/rates.html"/financial/rates"

  16. financial/claims.html"/financial/claims"

  17. rules/list.html"/rules/"

  18. security/audit.html"/security/audit"

Plus newer pages: security/reviews.html, security/nist.html, security/archive.html, security/changes.html, security/alerts.html

Verification

  1. Every list page renders pagination correctly

  2. Page links work (navigate to correct page with preserved filters)

  3. Ellipsis appears for large page counts

  4. "N total" shows correct count

  5. All E2E tests pass unchanged

  6. cargo check -p craig-web compiles

Files Touched

File Change

services/craig-web/templates/_pagination.html

New shared partial

~20 list templates

Replace inline pagination with {% include %}

~20 template structs in routes/*.rs

Add base_url field

Documentation Updates

  • CHANGELOG.adoc

Edit this page · latest