Phase 3: HTMX inline tag editing, swap animations, loading indicators, Alpine phone validation
This commit is contained in:
@@ -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"},
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user