fix: make community search page retain fields

Make community search page retain `topic_id`, `language_id`, and `search`

Refs: #362
This commit is contained in:
hono4kami 2024-12-17 18:15:36 +07:00 committed by hono4kami
parent ad55fc510c
commit b8178b650c

View file

@ -27,27 +27,45 @@
</div> </div>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<form action="/communities"
method="get"
hx-boost="true"
hx-trigger="change[event.target.matches('select[name=topic_id] select[name=language_id]')]">
{% if topics -%} {% if topics -%}
<form method="get" style="display:inline;">Topic: <div style="display:inline;">
<select name="topic_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a topic to filter communities by') }}"> Topic:
<select name="topic_id"
class="form-control-sm"
aria-label="{{ _('Choose a topic to filter communities by') }}">
<option value="0">All</option> <option value="0">All</option>
{% for topic in topics -%} {% for topic in topics -%}
<option value="{{ topic.id }}" {{ 'selected' if topic.id == topic_id }}>{{ topic.name }}</option> <option value="{{ topic.id }}" {{ 'selected' if topic.id == topic_id }}>{{ topic.name }}
</option>
{% endfor -%} {% endfor -%}
</select> </select>
</form> </div>
{% endif -%} {% endif -%}
{% if languages -%} {% if languages -%}
<form method="get" style="display:inline;">Language: <div style="display:inline;">
<select name="language_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a language to filter communities by') }}"> Language:
<select name="language_id"
class="form-control-sm"
aria-label="{{ _('Choose a language to filter communities by') }}">
<option value="0">All</option> <option value="0">All</option>
{% for language in languages -%} {% for language in languages -%}
<option value="{{ language.id }}" {{ 'selected' if language.id == language_id }}>{{ language.name }}</option> <option value="{{ language.id }}" {{ 'selected' if language.id == language_id }}>{{ language.name }}
</option>
{% endfor -%} {% endfor -%}
</select> </select>
</form> </div>
{% endif -%} {% endif -%}
<form method="get" style="display:inline;"><input type="search" name="search" placeholder="{{ _('Search') }}" value="{{ search }}"></form> <div style="display:inline;">
<input type="search"
name="search"
placeholder="{{ _('Search') }}"
value="{{ search }}">
</div>
</form>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<div class="btn-group"> <div class="btn-group">