brewlog/templates/partials/roast_list.html
2025-11-27 14:02:55 +00:00

96 lines
4.6 KiB
HTML

{% import "partials/table.html" as table %}
<div id="roast-list" class="mt-6" data-star-scope="roasts">
{% if roasts.items.is_empty() %}
<div
class="rounded-lg border border-dashed border-amber-300 bg-amber-100/40 px-4 py-6 text-sm text-stone-600"
>
<p class="text-center">No roasts recorded yet. Use the form above to add your first roast.</p>
</div>
{% else %}
<section class="rounded-lg border border-amber-300 bg-amber-100/80 shadow-sm">
{% call table::pagination_header(roasts, navigator, "#roast-list") %}
<div class="overflow-x-auto">
<table class="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, "#roast-list") %} {%
call table::sortable_header("Roast", "name", navigator, "#roast-list") %} {% call
table::sortable_header("Roaster", "roaster", navigator, "#roast-list") %} {% call
table::sortable_header("Origin", "origin", navigator, "#roast-list") %} {% call
table::sortable_header("Producer", "producer", navigator, "#roast-list") %}
<th scope="col" class="px-4 py-3">Notes</th>
{% if is_authenticated %}
<th scope="col" class="px-4 py-3 text-right">Actions</th>
{% endif %}
</tr>
</thead>
<tbody class="divide-y divide-amber-200/70">
{% for roast in roasts.items %}
<tr
data-star-key="{{ roast.full_id }}"
data-sort-created-at="{{ roast.created_at_sort_key }}"
data-sort-name="{{ roast.name }}"
data-sort-roaster="{{ roast.roaster_label }}"
data-sort-origin="{{ roast.origin }}"
data-sort-producer="{{ roast.producer }}"
class="bg-amber-50/40 transition hover:bg-amber-50"
>
<td class="whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
{{ roast.created_at }}
</td>
<td class="px-4 py-3">
<div class="flex flex-col">
<a
href="{{ roast.detail_path }}"
class="font-semibold text-amber-800 hover:text-amber-600"
>{{ roast.name }}</a
>
</div>
</td>
<td class="px-4 py-3 whitespace-nowrap">{{ roast.roaster_label }}</td>
<td class="px-4 py-3 whitespace-nowrap">{{ roast.origin }}</td>
<td class="px-4 py-3 whitespace-nowrap">{{ roast.producer }}</td>
<td class="px-4 py-3">
{% if roast.tasting_notes.is_empty() %}
<span class="text-xs text-stone-500">No tasting notes yet.</span>
{% else %}
<ul class="flex flex-wrap gap-2">
{% for note in roast.tasting_notes %}
<li>
<span
class="inline-flex items-center rounded-full border border-amber-500/60 bg-amber-500/10 px-3 py-1 text-xs font-semibold text-amber-700"
>{{ note }}</span
>
</li>
{% endfor %}
</ul>
{% endif %}
</td>
{% if is_authenticated %}
<td class="px-4 py-3 text-right">
<button
type="button"
class="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 roast"
data-on:click="confirm('Delete this roast?') && @delete('/api/v1/roasts/{{ roast.full_id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#roast-list', mode: 'replace'}})"
>
<span class="sr-only">Delete</span>
<svg class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path
fill-rule="evenodd"
d="M7.5 3a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1H15a1 1 0 1 1 0 2h-.4l-.74 10.36A2 2 0 0 1 11.87 17H8.13a2 2 0 0 1-1.99-1.64L5.4 5H5a1 1 0 1 1 0-2h2.5Zm.9 4.5a.75.75 0 0 1 .75.75v6a.75.75 0 1 1-1.5 0v-6a.75.75 0 0 1 .75-.75Zm3.4 0a.75.75 0 0 1 .75.75v6a.75.75 0 1 1-1.5 0v-6a.75.75 0 0 1 .75-.75Z"
clip-rule="evenodd"
/>
</svg>
</button>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endif %}
</div>