Adding filtering to tables

This commit is contained in:
Ian Roddis committed 2026-07-02 14:36:43 -03:00
1 parent d67b4ceb65
commit a50fccd56d
10 files changed
+329 -81

No files matched your search

+38 -22
View File
@@ -5,28 +5,44 @@
{% if sync_error %}
<p class="alert alert-error">{{ sync_error }}</p>
{% endif %}
<div class="card">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>SKU</th>
<th>Description</th>
<th>Colour</th>
<th>Manufacturer</th>
<th>Model</th>
<th>Type</th>
<th>Sub Type</th>
<th></th>
</tr>
</thead>
<tbody>
{% for ap in augmented_parts %}
{% include "admin/_augmented_part_row.html" %}
{% else %}
<tr><td colspan="9" class="muted">No augmented parts recorded.</td></tr>
<div class="filter-bar">
<form hx-get="/admin/augmented-parts/filter"
hx-target="#augmented-parts-table-card"
hx-trigger="input delay:300ms, change"
hx-swap="outerHTML">
<input type="text" name="description" placeholder="Filter by description…" value="{{ filter_description or '' }}">
<select name="colour_id">
<option value="">All colours</option>
{% for pc in part_colours %}
<option value="{{ pc.id }}" {{ "selected" if filter_colour_id and filter_colour_id|int == pc.id }}>{{ pc.name }}</option>
{% endfor %}
</tbody>
</table>
</select>
<select name="manufacturer_id">
<option value="">All manufacturers</option>
{% for m in manufacturers %}
<option value="{{ m.id }}" {{ "selected" if filter_manufacturer_id and filter_manufacturer_id|int == m.id }}>{{ m.name }}</option>
{% endfor %}
</select>
<select name="scope_model_id">
<option value="">All models</option>
{% for sm in scope_models %}
<option value="{{ sm.id }}" {{ "selected" if filter_scope_model_id and filter_scope_model_id|int == sm.id }}>{{ sm.name }}</option>
{% endfor %}
</select>
<select name="part_type_id">
<option value="">All types</option>
{% for pt in part_types %}
<option value="{{ pt.id }}" {{ "selected" if filter_part_type_id and filter_part_type_id|int == pt.id }}>{{ pt.name }}</option>
{% endfor %}
</select>
<select name="sub_part_type_id">
<option value="">All sub types</option>
{% for spt in sub_part_types %}
<option value="{{ spt.id }}" {{ "selected" if filter_sub_part_type_id and filter_sub_part_type_id|int == spt.id }}>{{ spt.name }}</option>
{% endfor %}
</select>
</form>
</div>
{% include "admin/_augmented_parts_table_card.html" %}
</div>