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">«</a>
{% else %}
<span class="pagination-bar__page pagination-bar__page--disabled">«</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:
-
cases/list.html— base_url:"/cases/" -
intake/referrals.html—"/intake/referrals" -
intake/investigations.html/intake/worklist.html—"/intake/worklist" -
intake/reports.html—"/intake/reports" -
placement/homes.html—"/placement/homes" -
placement/placements.html—"/placement/list" -
placement/matching.html—"/placement/matching" -
placement/education.html—"/placement/education" -
placement/health.html—"/placement/health" -
exchange/partners.html—"/exchange/partners" -
exchange/agreements.html—"/exchange/agreements" -
exchange/transactions.html—"/exchange/transactions" -
exchange/icpc.html—"/exchange/icpc" -
financial/payments.html—"/financial/payments" -
financial/rates.html—"/financial/rates" -
financial/claims.html—"/financial/claims" -
rules/list.html—"/rules/" -
security/audit.html—"/security/audit"
Plus newer pages: security/reviews.html, security/nist.html, security/archive.html, security/changes.html, security/alerts.html
Verification
-
Every list page renders pagination correctly
-
Page links work (navigate to correct page with preserved filters)
-
Ellipsis appears for large page counts
-
"N total" shows correct count
-
All E2E tests pass unchanged
-
cargo check -p craig-webcompiles
Files Touched
| File | Change |
|---|---|
|
New shared partial |
~20 list templates |
Replace inline pagination with |
~20 template structs in |
Add |