Skip to content

Commit 8c7bad0

Browse files
authored
Merge pull request #2196 from OpenEnergyPlatform/issue-2169-pagination-filter
Issue 2169 pagination filter
2 parents a4dc92b + 3490c7b commit 8c7bad0

File tree

4 files changed

+43
-33
lines changed

4 files changed

+43
-33
lines changed

dataedit/templates/dataedit/dataedit_tablelist.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,21 @@ <h1 class="main-header__title">
5959
{% if tables_paginated.has_previous %}
6060
<li class="page-item">
6161
<a class="page-link"
62-
href="?page={{ tables_paginated.previous_page_number }}"
62+
href="?{{ params_wo_page }}&page={{ tables_paginated.previous_page_number }}"
6363
tabindex="-1"
6464
aria-disabled="true">Previous</a>
6565
</li>
6666
{% endif %}
6767
<li class="page-item active">
68-
<a class="page-link" href="?page={{ tables_paginated.number }}">
68+
<a class="page-link"
69+
href="?{{ params_wo_page }}&page={{ tables_paginated.number }}">
6970
{{ tables_paginated.number }}
7071
</a>
7172
</li>
7273
{% if tables_paginated.has_next %}
7374
<li class="page-item">
7475
<a class="page-link"
75-
href="?page={{ tables_paginated.next_page_number }}">Next</a>
76+
href="?{{ params_wo_page }}&page={{ tables_paginated.next_page_number }}">Next</a>
7677
</li>
7778
{% endif %}
7879
</ul>

dataedit/templates/dataedit/taggable_setting.html

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,36 @@
99
style="background:{{ t.color_hex }};
1010
color:{% readable_text_color t.color_hex %}">{{ t.name }}</a>
1111
{% endfor %}
12-
<button data-bs-toggle="collapse"
13-
data-bs-target="#tag_handler"
14-
class="btn btn-add btn-circle">{% fa5_icon 'plus' 'fas' %}</button>
15-
<div id="tag_handler" class="collapse">
16-
<form action="{% url 'dataedit:tags-add' %}" method="post">
17-
{% csrf_token %}
18-
<h4>Choose tags to attach:</h4>
19-
{% for t in all_tags %}
20-
<span>
21-
<input type="checkbox"
22-
class="hidden"
23-
name="tag_{{ t.pk }}"
24-
id="select_{{ t.pk }}"
25-
{% if t in selected %}checked{% endif %} />
26-
<label class="form-label"
27-
style="background:{{ t.color_hex }};
28-
color:{% readable_text_color t.color_hex %}"
29-
class="btn tag"
30-
for="select_{{ t.pk }}">{{ t.name }}</label>
31-
</span>
32-
{% endfor %}
33-
{% if table %}
34-
<input type="hidden" name="table" value="{{ table }}" />
35-
{% endif %}
36-
<input type="submit" class="btn btn-success" value="Apply" />
37-
<a type="button"
38-
class="btn btn-info"
39-
href="{% url 'dataedit:topic-list' %}">Edit</a>
40-
</form>
41-
</div>
12+
{% if is_admin %}
13+
<button data-bs-toggle="collapse"
14+
data-bs-target="#tag_handler"
15+
class="btn btn-add btn-circle">{% fa5_icon 'plus' 'fas' %}</button>
16+
<div id="tag_handler" class="collapse">
17+
<form action="{% url 'dataedit:tags-add' %}" method="post">
18+
{% csrf_token %}
19+
<h4>Choose tags to attach:</h4>
20+
{% for t in all_tags %}
21+
<span>
22+
<input type="checkbox"
23+
class="hidden"
24+
name="tag_{{ t.pk }}"
25+
id="select_{{ t.pk }}"
26+
{% if t in selected %}checked{% endif %} />
27+
<label class="form-label"
28+
style="background:{{ t.color_hex }};
29+
color:{% readable_text_color t.color_hex %}"
30+
class="btn tag"
31+
for="select_{{ t.pk }}">{{ t.name }}</label>
32+
</span>
33+
{% endfor %}
34+
{% if table %}
35+
<input type="hidden" name="table" value="{{ table }}" />
36+
{% endif %}
37+
<input type="submit" class="btn btn-success" value="Apply" />
38+
<a type="button"
39+
class="btn btn-info"
40+
href="{% url 'dataedit:topic-list' %}">Edit</a>
41+
</form>
42+
</div>
43+
{% endif %}
4244
</div>

dataedit/views.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ def tables_view(request: HttpRequest, topic: str) -> HttpResponse:
402402
searched_query_string = request.GET.get("query")
403403
searched_tag_ids = request.GET.getlist("tags")
404404

405+
# all query params without "page"
406+
params_wo_page = request.GET.copy()
407+
params_wo_page.pop("page", None)
408+
params_wo_page = params_wo_page.urlencode()
409+
405410
Tag.increment_usage_count_many(searched_tag_ids)
406411

407412
# find all tables (layzy query set) in this topic
@@ -426,6 +431,7 @@ def tables_view(request: HttpRequest, topic: str) -> HttpResponse:
426431
"tables_paginated": tables_paginated,
427432
"query": searched_query_string,
428433
"tags": searched_tag_ids,
434+
"params_wo_page": params_wo_page,
429435
"topic": topic,
430436
"doc_oem_builder_link": DOCUMENTATION_LINKS["oemetabuilder"],
431437
},

versions/changelogs/current.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ SPDX-License-Identifier: CC0-1.0
1818
- fixed year format in scenario bundles (#2091, #2102)
1919
- fix sorting of fact sheets (#1974)
2020
- fixed caching issues (#1818, #1822)
21+
- keep table filter when using pagination (#2169)
2122

2223
## Documentation updates
2324

0 commit comments

Comments
 (0)