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 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 -%}
<form method="get" style="display:inline;">Topic:
<select name="topic_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a topic to filter communities by') }}">
<div style="display:inline;">
Topic:
<select name="topic_id"
class="form-control-sm"
aria-label="{{ _('Choose a topic to filter communities by') }}">
<option value="0">All</option>
{% 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 -%}
</select>
</form>
</div>
{% endif -%}
{% if languages -%}
<form method="get" style="display:inline;">Language:
<select name="language_id" class="form-control-sm submit_on_change" aria-label="{{ _('Choose a language to filter communities by') }}">
<div style="display:inline;">
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>
<option value="{{ language.id }}" {{ 'selected' if language.id == language_id }}>{{ language.name }}
</option>
{% endfor -%}
</select>
</form>
</div>
{% 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 class="col-auto">
<div class="btn-group">