The server renders the dialogs (?dialog=delete|move) and answers a move that needs confirmation with the merge dialog itself, so the client no longer builds action URLs or interprets X-Merge-Available. Successful mutations send HX-Redirect, which hx.js turns into a history replace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
2.2 KiB
HTML
47 lines
2.2 KiB
HTML
{{/* Server-rendered dialogs, fetched with ?dialog=<name> and swapped into
|
|
#modal-host by htmx; modal.js supplies the chrome (backdrop, Escape, drag,
|
|
focus). Each dialog is a form that posts the action it offers, so the client
|
|
never builds action URLs itself. Responses to those posts either redirect
|
|
(HX-Redirect), replace the dialog with the next step (e.g. the merge
|
|
confirmation), or fail with a plain-text error. */}}
|
|
|
|
{{define "delete"}}<div class="modal-backdrop">
|
|
<form class="modal panel panel-floating" role="dialog" aria-modal="true" aria-labelledby="modal-title" hx-post="?delete=1" hx-target="#modal-host">
|
|
<div class="panel-header"><span id="modal-title">Delete page</span></div>
|
|
<div class="panel-body">Delete {{.Path}} and everything inside it?</div>
|
|
<div class="panel-footer">
|
|
<button class="btn danger" type="submit">DELETE</button>
|
|
<button class="btn" type="button" data-modal-close autofocus>CANCEL</button>
|
|
</div>
|
|
</form>
|
|
</div>{{end}}
|
|
|
|
{{define "move"}}<div class="modal-backdrop">
|
|
<form class="modal panel panel-floating" role="dialog" aria-modal="true" aria-labelledby="modal-title" hx-post="?move" hx-target="#modal-host">
|
|
<div class="panel-header"><span id="modal-title">Move — new name?</span></div>
|
|
<div class="panel-body">
|
|
<input type="hidden" name="parent" value="{{.Parent}}" />
|
|
<input class="input" type="text" name="name" value="{{.Name}}" placeholder="Page name" required autofocus />
|
|
</div>
|
|
<div class="panel-footer">
|
|
<button class="btn" type="button" data-modal-close>CANCEL</button>
|
|
<button class="btn" type="submit">MOVE</button>
|
|
</div>
|
|
</form>
|
|
</div>{{end}}
|
|
|
|
{{define "merge"}}<div class="modal-backdrop">
|
|
<form class="modal panel panel-floating" role="dialog" aria-modal="true" aria-labelledby="modal-title" hx-post="?move" hx-target="#modal-host">
|
|
<div class="panel-header"><span id="modal-title">Merge folders?</span></div>
|
|
<div class="panel-body">
|
|
The destination folder already exists but has no page of its own. Merge this page and its contents into it?
|
|
<input type="hidden" name="move" value="{{.Dest}}" />
|
|
<input type="hidden" name="merge" value="1" />
|
|
</div>
|
|
<div class="panel-footer">
|
|
<button class="btn" type="button" data-modal-close>CANCEL</button>
|
|
<button class="btn" type="submit" autofocus>MERGE</button>
|
|
</div>
|
|
</form>
|
|
</div>{{end}}
|