diff options
Diffstat (limited to 'internal/handlers/handlers.go')
| -rw-r--r-- | internal/handlers/handlers.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index e427e40..343d0b1 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -488,6 +488,31 @@ func (h *Handler) HandleCompleteCard(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } +// HandleDeferAtom returns an active maintenance-bucket item to its pool +// without crediting it as done -- distinct from complete/uncomplete. +// Doot-native tasks only (bucket items don't exist for other sources). +// No special swap needed: a successful defer removes the task's due date, +// so the same timeline refresh that follows completion just makes it +// disappear from the current view like any other now-undated task would. +func (h *Handler) HandleDeferAtom(w http.ResponseWriter, r *http.Request) { + if err := r.ParseForm(); err != nil { + JSONError(w, http.StatusBadRequest, "Failed to parse form", err) + return + } + id := r.FormValue("id") + if id == "" { + JSONError(w, http.StatusBadRequest, "Missing id", nil) + return + } + if err := h.store.DeferNativeTask(id); err != nil { + JSONError(w, http.StatusInternalServerError, "Failed to defer task", err) + return + } + w.Header().Set("HX-Reswap", "none") + w.Header().Set("HX-Trigger", "refresh-tasks") + w.WriteHeader(http.StatusOK) +} + // HandleCompleteAtom handles completion of a unified task (Atom) func (h *Handler) HandleCompleteAtom(w http.ResponseWriter, r *http.Request) { h.handleAtomToggle(w, r, true) |
