Fix params in topic list being lost on page change

This commit is contained in:
rubenwardy 2018-12-25 18:10:31 +00:00
parent f5744f5188
commit b10660030a
2 changed files with 12 additions and 7 deletions

@ -54,7 +54,10 @@ Topics to be Added
</div>
<form method="GET" action="{{ url_for('todo_topics_page') }}" class="my-4">
<input class="" name="q" type="text" placeholder="Search topics" value="{{ query or ''}}">
<input type="hidden" name="show_discarded" value={{ show_discarded and "True" or "False" }} />
<input type="hidden" name="n" value={{ n }} />
<input type="hidden" name="sort" value={{ sort_by or "date" }} />
<input name="q" type="text" placeholder="Search topics" value="{{ query or ''}}">
<input class="btn btn-secondary my-2 my-sm-0 mr-sm-2" type="submit" value="Search" />
</form>
@ -65,11 +68,11 @@ Topics to be Added
<li class="page-item {% if not prev_url %}disabled{% endif %}">
<a class="page-link" {% if prev_url %}href="{{ prev_url }}"{% endif %}>&laquo;</a>
</li>
{% for n in range(1, page_max+1) %}
<li class="page-item {% if n == page %}active{% endif %}">
{% for i in range(1, page_max+1) %}
<li class="page-item {% if i == page %}active{% endif %}">
<a class="page-link"
href="{{ url_for('todo_topics_page', page=n) }}">
{{ n }}
href="{{ url_for('todo_topics_page', page=i, query=query, show_discarded=show_discarded, n=n, sort=sort_by) }}">
{{ i }}
</a>
</li>
{% endfor %}

@ -83,9 +83,11 @@ def todo_topics_page():
num = 100
query = query.paginate(page, num, True)
next_url = url_for("todo_topics_page", page=query.next_num) \
next_url = url_for("todo_topics_page", page=query.next_num, query=search, \
show_discarded=show_discarded, n=num, sort=sort_by) \
if query.has_next else None
prev_url = url_for("todo_topics_page", page=query.prev_num) \
prev_url = url_for("todo_topics_page", page=query.prev_num, query=search, \
show_discarded=show_discarded, n=num, sort=sort_by) \
if query.has_prev else None
return render_template("todo/topics.html", topics=query.items, total=total, \