Move list partials outside the section element on bags, gear, and brews pages so they become separate flex children of <main>, matching the pattern used by roasters, roasts, cafes, and cups. Add mt-6 to each partial's outer div for consistent spacing. Standardise brew and gear list partials to match the canonical structure: empty-state conditional with dashed amber border, <section> wrapper for the table, and data-star-scope attribute on the outer div. Update CLAUDE.md to document page template and list partial structure requirements, preventing future drift.
135 lines
5.6 KiB
HTML
135 lines
5.6 KiB
HTML
{% import "partials/table.html" as table %}
|
|
|
|
<div id="bag-list" class="mt-6 space-y-8" data-star-scope="bags">
|
|
{% if !open_bags.is_empty() %}
|
|
<section>
|
|
<h2 class="text-2xl font-bold mb-4 text-stone-800">Open Bags</h2>
|
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
{% for bag in open_bags %}
|
|
<div class="bg-white rounded-lg shadow-md overflow-hidden border border-stone-200">
|
|
<div class="p-6">
|
|
<div class="flex justify-between items-start mb-4">
|
|
<div>
|
|
<h3 class="text-xl font-semibold text-stone-900">
|
|
<a
|
|
href="/roasters/{{ bag.roaster_slug }}"
|
|
class="hover:text-amber-700 hover:underline"
|
|
>
|
|
{{ bag.roaster_name }}
|
|
</a>
|
|
</h3>
|
|
<p class="text-stone-600">
|
|
<a
|
|
href="/roasters/{{ bag.roaster_slug }}/roasts/{{ bag.roast_slug }}"
|
|
class="hover:text-amber-700 hover:underline"
|
|
>
|
|
{{ bag.roast_name }}
|
|
</a>
|
|
</p>
|
|
</div>
|
|
<span class="px-2 py-1 text-xs font-semibold rounded-full bg-green-100 text-green-800">
|
|
Open
|
|
</span>
|
|
</div>
|
|
|
|
<div class="space-y-2 text-sm text-stone-500 mb-4">
|
|
<div class="flex items-center">
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
class="h-4 w-4 mr-2"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
>
|
|
<path
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="2"
|
|
d="M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3"
|
|
/>
|
|
</svg>
|
|
<span>{{ bag.remaining }} / {{ bag.amount }}g</span>
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
<svg
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
class="h-4 w-4 mr-2"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor"
|
|
>
|
|
<path
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
stroke-width="2"
|
|
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
/>
|
|
</svg>
|
|
{% if let Some(roast_date) = bag.roast_date %}
|
|
<span>Roasted {{ roast_date }}</span>
|
|
{% else %}
|
|
<span>Added {{ bag.created_at }}</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
{% if is_authenticated %}
|
|
<div class="pt-4 border-t border-stone-100 flex justify-end">
|
|
<button
|
|
class="text-sm text-stone-600 hover:text-stone-900 font-medium"
|
|
data-on:click="@put('/api/v1/bags/{{ bag.id }}?{{ navigator.query() }}&closed=true&remaining=0.0&finished_at=' + new Date().toISOString().split('T')[0], {responseOverrides: {selector: '#bag-list', mode: 'replace'}})"
|
|
>
|
|
Finish Bag
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</section>
|
|
{% endif %}
|
|
|
|
<section>
|
|
<h2 class="text-2xl font-bold mb-4 text-stone-800">History</h2>
|
|
<div class="rounded-lg border border-amber-300 bg-amber-100/80 shadow-sm"
|
|
{% if bags.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(bags.next_page().unwrap())|safe }}" data-target="#bag-list"{% endif %}
|
|
>
|
|
{% call table::search_header(navigator, "#bag-list") %}
|
|
|
|
<div class="overflow-x-auto">
|
|
<table class="responsive-table min-w-full divide-y divide-amber-200 text-left text-sm text-stone-700">
|
|
<thead class="bg-amber-200/60 text-xs font-semibold tracking-wide text-amber-900">
|
|
<tr>
|
|
{% call table::sortable_header("Added", "created-at", navigator, "#bag-list") %}
|
|
{% call table::sortable_header("Roaster", "roaster", navigator, "#bag-list") %}
|
|
{% call table::sortable_header("Roast", "roast", navigator, "#bag-list") %}
|
|
<th scope="col" class="px-4 py-3">Weight</th>
|
|
{% call table::sortable_header("Finished", "finished-at", navigator, "#bag-list") %}
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-amber-200/70">
|
|
{% for bag in bags.items %}
|
|
<tr class="bg-amber-50/40 transition hover:bg-amber-50">
|
|
<td data-label="Added" class="whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
|
|
{{ bag.created_at }}
|
|
</td>
|
|
<td data-label="Roaster" class="px-4 py-3 whitespace-nowrap font-medium text-stone-600">
|
|
{{ bag.roaster_name }}
|
|
</td>
|
|
<td data-label="Roast" class="px-4 py-3 whitespace-nowrap">{{ bag.roast_name }}</td>
|
|
<td data-label="Weight" class="px-4 py-3 whitespace-nowrap">{{ bag.amount }}g</td>
|
|
<td data-label="Finished" class="px-4 py-3 whitespace-nowrap">{{ bag.finished_at }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% call table::pagination_header(bags, navigator, "#bag-list") %}
|
|
{% if bags.has_next() %}
|
|
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
|
|
{% endif %}
|
|
</div>
|
|
</section>
|
|
</div>
|