brewlog/templates/pages/gear.html
Jon Seager 958c8de6cc
feat(detail): add roaster, cafe, and gear detail pages
- Add detail page routes, templates, and view models for roasters, cafes,
  and gear, following the existing pattern from bags/brews/cups
- Add map_with_legend_1 macro for single-country detail maps
- Redirect to detail page after entity creation instead of list page
- Check referer in create handlers to return list fragment only from data page
- Update bag delete button to use red background style
- Update datastar tests to include referer header for create assertions
2026-02-08 17:20:46 +00:00

62 lines
2.2 KiB
HTML

{% extends "base.html" %}
{% import "partials/detail_cards.html" as detail %}
{% import "partials/icons.html" as icons %}
{% block title %}Brewlog · {{ gear.make }} {{ gear.model }}{% endblock %}
{% block og_title %}{{ gear.make }} {{ gear.model }} — Brewlog{% endblock %}
{% block og_description %}{{ gear.make }} {{ gear.model }} — {{ gear.category_label }}{% endblock %}
{% block head %}<meta property="og:image" content="{{ base_url }}/og-image.png" />{% endblock %}
{% block content %}
<header class="flex items-start justify-between gap-4">
<div class="flex flex-col gap-2">
<h1 class="text-3xl font-semibold">{{ gear.make }} {{ gear.model }}</h1>
<p class="text-sm text-text-secondary">
{{ gear.category_label }} · Added {{ gear.created_date }}
</p>
</div>
{{ detail::share_button() }}
</header>
{{ detail::share_script() }}
<div class="rounded-lg border bg-surface p-5">
<h2 class="text-lg font-semibold text-text mb-4">Details</h2>
<dl class="grid grid-cols-2 gap-x-4 gap-y-3 text-sm">
<div>
<dt class="text-text-muted">Category</dt>
<dd class="font-medium text-text">{{ gear.category_label }}</dd>
</div>
<div>
<dt class="text-text-muted">Make</dt>
<dd class="font-medium text-text">{{ gear.make }}</dd>
</div>
<div>
<dt class="text-text-muted">Model</dt>
<dd class="font-medium text-text">{{ gear.model }}</dd>
</div>
</dl>
</div>
{% if is_authenticated %}
<div class="rounded-lg border bg-surface p-5 flex items-center gap-2">
<button type="button" onclick="deleteGear('{{ gear.id }}')"
class="inline-flex items-center gap-2 rounded-md bg-red-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-red-700">
{{ icons::delete("h-4 w-4") }} Delete
</button>
</div>
<script>
const deleteGear = async (id) => {
if (!confirm('Delete this gear? This cannot be undone.')) return;
try {
const resp = await fetch(`/api/v1/gear/${id}`, {
method: 'DELETE',
credentials: 'same-origin',
});
if (!resp.ok) throw new Error(`Server returned ${resp.status}`);
window.location.href = '/data?type=gear';
} catch (e) {
alert(`Failed to delete gear: ${e.message}`);
}
};
</script>
{% endif %}
{% endblock %}