Phase 3: HTMX inline tag editing, swap animations, loading indicators, Alpine phone validation

This commit is contained in:
2026-08-07 18:18:49 +10:00
parent e264125214
commit aa023cf89e
9 changed files with 87 additions and 9 deletions

View File

@@ -52,7 +52,7 @@ func LoadTemplates() (Templates, error) {
"index": {dir + "/index.html"},
"register": {dir + "/register.html"},
"login": {dir + "/login.html"},
"account": {dir + "/account.html", dir + "/account-panel.html", dir + "/tag-list.html"},
"account": {dir + "/account.html", dir + "/account-panel.html", dir + "/tag-list.html", dir + "/tag-edit-inline.html"},
"edit": {dir + "/tag-edit.html"},
"public": {dir + "/tag-public.html"},
"notfound": {dir + "/not-found.html"},

View File

@@ -87,6 +87,16 @@ func (a *App) EditTagPage(w http.ResponseWriter, r *http.Request) {
a.render(w, r, "edit", "Edit tag", tag, "")
}
// EditInlinePage returns the compact inline edit form for HTMX row editing.
func (a *App) EditInlinePage(w http.ResponseWriter, r *http.Request) {
uid, _ := auth.GetUserID(r)
tag, ok := a.loadOwnedTag(w, r, uid)
if !ok {
return
}
a.renderPartial(w, "account", "tag-edit-inline", tag)
}
func (a *App) EditTag(w http.ResponseWriter, r *http.Request) {
uid, _ := auth.GetUserID(r)
tag, ok := a.loadOwnedTag(w, r, uid)
@@ -112,6 +122,16 @@ func (a *App) EditTag(w http.ResponseWriter, r *http.Request) {
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
// If this was an HTMX inline edit, return the refreshed account panel.
if r.Header.Get("HX-Request") == "true" {
tags, err := a.Queries.ListTagsByOwner(r.Context(), ownerID(uid))
if err != nil {
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
a.renderPartial(w, "account", "account-panel", accountData{Tags: tags})
return
}
http.Redirect(w, r, "/account", http.StatusSeeOther)
}