Show a simple "No X added yet" for unauthenticated visitors. Authenticated users see a prompt to click the Add button.
131 lines
6.5 KiB
HTML
131 lines
6.5 KiB
HTML
{% import "partials/table.html" as table %}
|
|
{% import "partials/icons.html" as icons %}
|
|
|
|
<div id="cafe-list" class="mt-6" data-star-scope="cafes">
|
|
{% if cafes.items.is_empty() && !navigator.has_search() %}
|
|
<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">
|
|
{% if is_authenticated %}
|
|
No cafes added yet. Click the Add button to add your first cafe.
|
|
{% else %}
|
|
No cafes added yet.
|
|
{% endif %}
|
|
</p>
|
|
</div>
|
|
{% else %}
|
|
<section class="rounded-lg border border-amber-300 bg-amber-100/80 shadow-sm"
|
|
{% if cafes.has_next() %}data-infinite-scroll data-next-url="{{ navigator.fragment_page_href(cafes.next_page().unwrap())|safe }}" data-target="#cafe-list"{% endif %}
|
|
>
|
|
{% call table::search_header(navigator, "#cafe-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, "#cafe-list") %}
|
|
{% call table::sortable_header("Name", "name", navigator, "#cafe-list") %}
|
|
{% call table::sortable_header("Location", "country", navigator, "#cafe-list") %}
|
|
<th scope="col" class="px-4 py-3 text-right">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-amber-200/70">
|
|
{% for cafe in cafes.items %}
|
|
<tr
|
|
data-star-key="{{ cafe.id }}"
|
|
data-sort-created-at="{{ cafe.created_at_sort_key }}"
|
|
data-sort-name="{{ cafe.name }}"
|
|
data-sort-country="{{ cafe.country }}"
|
|
data-sort-city="{{ cafe.city }}"
|
|
class="bg-amber-50/40 transition hover:bg-amber-50"
|
|
>
|
|
<td data-label="Added" class="card-date whitespace-nowrap px-4 py-3 text-xs font-medium text-stone-600">
|
|
{{ cafe.created_at }}
|
|
</td>
|
|
<td data-label="Name" class="card-title px-4 py-3 font-medium text-stone-800">
|
|
{{ cafe.name }}
|
|
</td>
|
|
<td data-label="Location" class="px-4 py-3 whitespace-nowrap">
|
|
{{ cafe.country }}
|
|
<div class="hidden md:block text-xs text-stone-500">{{ cafe.city }}</div>
|
|
</td>
|
|
<td data-label="City" class="px-4 py-3 whitespace-nowrap md:hidden">{{ cafe.city }}</td>
|
|
<td data-label="" class="card-actions px-4 py-3 text-right">
|
|
<div class="hidden md:inline-flex items-center gap-1">
|
|
<a
|
|
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-500 transition hover:text-amber-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-500"
|
|
href="{{ cafe.map_url }}"
|
|
target="_blank"
|
|
rel="noreferrer noopener"
|
|
title="Open in Google Maps"
|
|
>
|
|
<span class="sr-only">Open {{ cafe.name }} in Google Maps</span>
|
|
{% call icons::location("h-4 w-4") %}
|
|
</a>
|
|
{% if cafe.has_website %}
|
|
<a
|
|
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-500 transition hover:text-amber-700 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-500"
|
|
href="{{ cafe.website_url }}"
|
|
target="_blank"
|
|
rel="noreferrer noopener"
|
|
title="Visit website"
|
|
>
|
|
<span class="sr-only">Visit {{ cafe.name }} website</span>
|
|
{% call icons::external_link("h-4 w-4") %}
|
|
</a>
|
|
{% else %}
|
|
<span
|
|
class="inline-flex h-8 w-8 items-center justify-center rounded-md text-stone-300 cursor-default"
|
|
title="No website"
|
|
aria-disabled="true"
|
|
>
|
|
{% call icons::external_link("h-4 w-4") %}
|
|
</span>
|
|
{% endif %}
|
|
{% if is_authenticated %}
|
|
<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 cafe"
|
|
data-on:click="confirm('Delete this cafe?') && @delete('/api/v1/cafes/{{ cafe.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#cafe-list', mode: 'replace'}})"
|
|
>
|
|
<span class="sr-only">Delete</span>
|
|
{% call icons::delete("h-4 w-4") %}
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
<details class="card-menu md:hidden">
|
|
<summary>{% call icons::ellipsis_vertical("h-5 w-5") %}</summary>
|
|
<div class="card-menu-items">
|
|
<a href="{{ cafe.map_url }}" target="_blank" rel="noreferrer noopener">
|
|
{% call icons::location("h-4 w-4") %} View on map
|
|
</a>
|
|
{% if cafe.has_website %}
|
|
<a href="{{ cafe.website_url }}" target="_blank" rel="noreferrer noopener">
|
|
{% call icons::external_link("h-4 w-4") %} Visit website
|
|
</a>
|
|
{% endif %}
|
|
{% if is_authenticated %}
|
|
<button type="button" class="menu-item-danger"
|
|
data-on:click="this.closest('details').open = false; confirm('Delete this cafe?') && @delete('/api/v1/cafes/{{ cafe.id }}?{{ navigator.query() }}', {responseOverrides: {selector: '#cafe-list', mode: 'replace'}})">
|
|
{% call icons::delete("h-4 w-4") %} Delete
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
</details>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{% if cafes.items.is_empty() %}
|
|
<div class="p-8 text-center text-stone-500">No cafes match your search.</div>
|
|
{% endif %}
|
|
{% call table::pagination_header(cafes, navigator, "#cafe-list") %}
|
|
{% if cafes.has_next() %}
|
|
<div class="infinite-scroll-sentinel h-4 md:hidden" aria-hidden="true"></div>
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
</div>
|