brewlog/templates/partials/lists/gear_list.html
Jon Seager 56109f3afe
refactor: reorganize templates into pages/, partials/lists/, and forms/
Move 9 page templates to templates/pages/, nav to partials/,
7 list partials + table.html to partials/lists/. Extract duplicated
scan result form (~85 lines) from home.html and add.html into
partials/forms/scan_result_form.html. Update all Askama template
paths, include/import directives.
2026-02-05 17:48:18 +00:00

88 lines
4.2 KiB
HTML

{% import "partials/lists/table.html" as table %}
{% import "partials/icons.html" as icons %}
<div id="gear-list" class="mt-6" data-star-scope="gear">
{% if gear.items.is_empty() && !navigator.has_search() %}
<div
class="rounded-lg border border-dashed px-4 py-6 text-sm text-stone-600"
>
<p class="text-center">
{% if is_authenticated %}
No gear added yet. Click the Add button to add your first piece of equipment.
{% else %}
No gear added yet.
{% endif %}
</p>
</div>
{% else %}
<section class="rounded-lg border bg-surface"
{% if gear.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(gear.next_page().unwrap())|safe }}" data-target="#gear-list"{% endif %}
>
{% call table::search_header(navigator, "#gear-list") %}
<div class="overflow-x-auto">
<table class="responsive-table min-w-full divide-y text-left text-sm text-stone-700">
<thead class="bg-surface-alt text-xs font-semibold tracking-wide text-stone-700">
<tr>
{% call table::sortable_header("Added", "created-at", navigator, "#gear-list") %}
{% call table::sortable_header("Category", "category", navigator, "#gear-list") %}
{% call table::sortable_header("Make", "make", navigator, "#gear-list") %}
{% call table::sortable_header("Model", "model", navigator, "#gear-list") %}
{% if is_authenticated %}
<th scope="col" class="px-4 py-3 text-right">Actions</th>
{% endif %}
</tr>
</thead>
<tbody class="divide-y/70">
{% for item in gear.items %}
<tr class="transition hover:bg-surface-alt">
<td data-label="Added" class="card-date whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
{{ item.created_at }}
</td>
<td data-label="" class="card-title px-4 py-3 whitespace-nowrap md:hidden">{{ item.make }} {{ item.model }}</td>
<td data-label="Category" class="px-4 py-3 whitespace-nowrap">
{{ item.category_label }}
</td>
<td data-label="Make" class="mobile-hidden px-4 py-3 whitespace-nowrap font-medium text-stone-600">
{{ item.make }}
</td>
<td data-label="Model" class="mobile-hidden px-4 py-3 whitespace-nowrap">
{{ item.model }}
</td>
{% if is_authenticated %}
<td data-label="" class="card-actions px-4 py-3 text-right">
<button
type="button"
class="hidden md:inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-500 transition hover:text-red-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-red-500"
title="Delete gear"
data-on:click="confirm('Delete this gear?') && @delete('/api/v1/gear/{{ item.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#gear-list', mode: 'replace'}})"
>
<span class="sr-only">Delete</span>
{% call icons::delete("h-4 w-4") %}
</button>
<details class="card-menu md:hidden">
<summary>{% call icons::ellipsis_vertical("h-5 w-5") %}</summary>
<div class="card-menu-items">
<button type="button" class="menu-item-danger"
data-on:click="this.closest('details').open = false; confirm('Delete this gear?') && @delete('/api/v1/gear/{{ item.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#gear-list', mode: 'replace'}})">
{% call icons::delete("h-4 w-4") %} Delete
</button>
</div>
</details>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% if gear.items.is_empty() %}
<div class="p-8 text-center text-stone-500">No gear matches your search.</div>
{% endif %}
{% call table::pagination_header(gear, navigator, "#gear-list") %}
{% if gear.has_next() %}
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
{% endif %}
</section>
{% endif %}
</div>