Two modal pipelines coexisted after the URL-addressable pilot — modal.js
(inline, ~30 lines) and modal-router.js (routed, ~150 lines) — operating
on different attribute namespaces and exposing different APIs. Future
modal authors had two systems to learn with no naming convention to
help them pick the right one for a given use case.
Consolidates both into static/js/modals.js with two clearly-named
pipelines and a single window.modals.* API:
Inline modal — content pre-rendered in the page.
Hooks: data-inline-modal-open="<dialog-id>"
data-inline-modal-close
API: window.modals.openInline(idOrEl)
window.modals.closeInline(idOrEl)
Use: confirmations, transient prompts, in-page forms without
URL value.
Routed modal — content fetched from a URL, ?modal=<path> in URL,
with history + share-link + refresh-survival.
Hooks: <a data-routed-modal href="<path>">
data-routed-modal-dismiss
API: window.modals.openRouted(path)
window.modals.closeRouted()
Use: content with standalone-page meaning.
Single document-level click delegation handles all four attribute
hooks; one DOMContentLoaded handler binds dialog 'close' / 'cancel' /
backdrop on the routed slot; shared popstate and htmx:responseError
listeners. Behaviour unchanged — pure rename + colocation.
Renamed across 11 templates and files-overlay.js. Old data-modal-*
attributes and window.openModal/closeModal globals are gone — clean
break (no back-compat shims). AGENTS.md "Modals: inline vs routed"
section documents the decision guide for new modals.
Verified: 573 backend tests pass. 5/5 Chromium smoke checks pass
(inline open/close, Esc, backdrop, routed open+save, routed Esc).
Console clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.8 KiB
HTML
46 lines
1.8 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Blueprints | left4me{% endblock %}
|
|
|
|
{% block content %}
|
|
<section class="panel">
|
|
<div class="page-heading">
|
|
<h1>Blueprints</h1>
|
|
<button type="button" data-inline-modal-open="create-blueprint-modal">+ Create</button>
|
|
</div>
|
|
<table class="table">
|
|
<thead><tr><th>Name</th><th>Created</th><th>Updated</th><th>Actions</th></tr></thead>
|
|
<tbody>
|
|
{% for blueprint in blueprints %}
|
|
<tr>
|
|
<td><a href="/blueprints/{{ blueprint.id }}">{{ blueprint.name }}</a></td>
|
|
<td>{{ blueprint.created_at | timeago }}</td>
|
|
<td>{{ blueprint.updated_at | timeago }}</td>
|
|
<td><a href="/servers?blueprint_id={{ blueprint.id }}">Create server</a></td>
|
|
</tr>
|
|
{% else %}
|
|
<tr><td colspan="4" class="muted">No blueprints configured.</td></tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<dialog id="create-blueprint-modal" class="modal" aria-labelledby="create-blueprint-title">
|
|
<form method="post" action="/blueprints" class="stack">
|
|
<div class="modal-header">
|
|
<h2 id="create-blueprint-title">Create blueprint</h2>
|
|
<button type="button" class="modal-close" data-inline-modal-close aria-label="Close">×</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<input type="hidden" name="csrf_token" value="{{ session.get('csrf_token', '') }}">
|
|
<label>Name <input name="name" required></label>
|
|
<label>Arguments <textarea name="arguments" rows="8" spellcheck="false"></textarea></label>
|
|
<label>Config <textarea name="config" rows="8" spellcheck="false"></textarea></label>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="button-secondary" data-inline-modal-close>Cancel</button>
|
|
<button type="submit">Create blueprint</button>
|
|
</div>
|
|
</form>
|
|
</dialog>
|
|
{% endblock %}
|