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