Address findings from the templates code review: - Fix XSS in admin.html onclick handlers via data attributes - Fix XSS in 5 edit page signal initializations via JSON serialization - Fix register.html token exposure by moving to data attribute - Add entity_icon, quick_notes_toggles, add_form_submit macros - Replace hardcoded colors with design tokens (warning, error, success) - Add warning design tokens to CSS theme - Scope MutationObserver to main element - Add defer to webauthn.js script tags - Refactor login/register JS to arrow functions - Guard lightbox script behind image_url check - Fix else-if to elif in 5 templates
68 lines
2.4 KiB
HTML
68 lines
2.4 KiB
HTML
{% extends "base.html" %}
|
|
{% import "partials/icons.html" as icons %}
|
|
{% import "partials/image_section.html" as img %}
|
|
{% import "partials/detail_cards.html" as detail_cards %}
|
|
{% block title %}Brewlog · Edit Gear{% endblock %}
|
|
|
|
{% block content %}
|
|
<header class="flex flex-col gap-2">
|
|
<h1 class="text-3xl font-semibold">Edit Gear</h1>
|
|
<p class="max-w-2xl text-sm text-text-secondary">Update gear details.</p>
|
|
</header>
|
|
|
|
<section class="rounded-lg border bg-surface p-5">
|
|
<form
|
|
class="flex flex-col gap-4 pb-16 md:pb-0"
|
|
data-signals="{{ signals_json }}"
|
|
data-on:submit="$_submitting = true; $_submitError = ''; @put('/api/v1/gear/{{ id }}', {contentType: 'form'})"
|
|
data-on:datastar-fetch="if (!$_submitting) return;
|
|
if (evt.detail.type === 'finished') { $_submitting = false; sessionStorage.setItem('toast', 'Gear updated') }
|
|
else if (evt.detail.type === 'error') { $_submitting = false; $_submitError = 'Failed to save changes.' }"
|
|
>
|
|
<div class="grid gap-4 sm:grid-cols-3">
|
|
<div class="flex flex-col gap-1 text-sm">
|
|
<span
|
|
class="text-xs font-semibold text-text-muted uppercase tracking-wide"
|
|
>Category</span
|
|
>
|
|
<span
|
|
class="input-field bg-surface-alt text-text-secondary cursor-not-allowed"
|
|
>{{ category }}</span
|
|
>
|
|
</div>
|
|
<label class="flex flex-col gap-1 text-sm">
|
|
<span
|
|
class="text-xs font-semibold text-text-muted uppercase tracking-wide"
|
|
>Make*</span
|
|
>
|
|
<input
|
|
type="text"
|
|
name="make"
|
|
required
|
|
aria-required="true"
|
|
class="input-field"
|
|
placeholder="Baratza"
|
|
data-bind:_make
|
|
/>
|
|
</label>
|
|
<label class="flex flex-col gap-1 text-sm">
|
|
<span
|
|
class="text-xs font-semibold text-text-muted uppercase tracking-wide"
|
|
>Model*</span
|
|
>
|
|
<input
|
|
type="text"
|
|
name="model"
|
|
required
|
|
aria-required="true"
|
|
class="input-field"
|
|
placeholder="Encore"
|
|
data-bind:_model
|
|
/>
|
|
</label>
|
|
</div>
|
|
{{ img::deferred_upload_with_preview("edit-gear-image", "Gear Image", "gear", id, image_url) }}
|
|
{{ detail_cards::edit_form_actions() }}
|
|
</form>
|
|
</section>
|
|
{% endblock %}
|