From cda9089980d8207d4907c573ce88e73c4545a435 Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Sun, 23 Apr 2017 02:55:04 +0200 Subject: [PATCH] fixed highlighting of active page for pagination --- templates/changelog.html | 8 ++++++-- templates/jobs_overview.html | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/templates/changelog.html b/templates/changelog.html index b721581..ec76f03 100644 --- a/templates/changelog.html +++ b/templates/changelog.html @@ -15,8 +15,12 @@ <span class="sr-only">Previous</span> </a> </li> - {% for i in range(max(0, pagecount - 5) ,min(pagecount, pagecount + 5)) %} - <li class="page-item"><a class="page-link" href="{{url_for('changelog', page=i) }}">{{ i }}</a></li> + {% for i in range(max(0, page - 5) ,min(pagecount, page + 5)) %} + {% if i == page %} + <li class="page-item active"><a class="page-link" href="{{url_for('changelog', page=i) }}">{{ i }}</a></li> + {% else %} + <li class="page-item"><a class="page-link" href="{{url_for('changelog', page=i) }}">{{ i }}</a></li> + {% endif %} {% endfor %} <li class="page-item"> <a class="page-link" href="{{url_for('changelog', page=page+1) }}"> diff --git a/templates/jobs_overview.html b/templates/jobs_overview.html index c7b7ea9..1496e5f 100644 --- a/templates/jobs_overview.html +++ b/templates/jobs_overview.html @@ -78,8 +78,12 @@ <span class="sr-only">Previous</span> </a> </li> - {% for i in range(max(0, pagecount - 5) ,min(pagecount, pagecount + 5)) %} - <li class="page-item"><a class="page-link" href="{{url_for('jobs_overview', page=i, **(request.args|filterdict(['page','pagesize']))) }}">{{ i }}</a></li> + {% for i in range(max(0, page - 5) ,min(pagecount, page + 5)) %} + {% if i == page %} + <li class="page-item active"><a class="page-link" href="{{url_for('jobs_overview', page=i, **(request.args|filterdict(['page','pagesize']))) }}">{{ i }}</a></li> + {% else %} + <li class="page-item"><a class="page-link" href="{{url_for('jobs_overview', page=i, **(request.args|filterdict(['page','pagesize']))) }}">{{ i }}</a></li> + {% endif %} {% endfor %} <li class="page-item"> <a class="page-link" href="{{url_for('jobs_overview', page=page+1, **(request.args|filterdict(['page','pagesize']))) }}"> -- GitLab