summaryrefslogtreecommitdiff
path: root/internal/handlers/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers/handlers.go')
-rw-r--r--internal/handlers/handlers.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go
index 343d0b1..54c6a70 100644
--- a/internal/handlers/handlers.go
+++ b/internal/handlers/handlers.go
@@ -3,6 +3,7 @@ package handlers
import (
"context"
"crypto/rand"
+ "errors"
"fmt"
"html/template"
"log"
@@ -46,6 +47,7 @@ func New(s *store.Store, trello api.TrelloAPI, planToEat api.PlanToEatAPI, googl
// Template functions
funcMap := template.FuncMap{
"subtract": func(a, b int) int { return a - b },
+ "add": func(a, b int) int { return a + b },
// multiDayLabel returns the "(starts/ends HH:MM)" suffix for a
// multi-day calendar event's row on the day it's rendered, or ""
// for a normal item or a "spans" (pass-through) day, which shows
@@ -580,6 +582,10 @@ func (h *Handler) handleAtomToggle(w http.ResponseWriter, r *http.Request, compl
}
if err != nil {
+ if errors.Is(err, store.ErrChainTaskLocked) {
+ JSONError(w, http.StatusBadRequest, "Task is locked in its chain", err)
+ return
+ }
action := "complete"
if !complete {
action = "reopen"
@@ -858,6 +864,11 @@ func (h *Handler) HandleTabTasks(w http.ResponseWriter, r *http.Request) {
return
}
+ chainSummaries, err := BuildChainSummaries(h.store)
+ if err != nil {
+ log.Printf("Warning: failed to build chain summaries: %v", err)
+ }
+
SortAtomsByUrgency(atoms)
currentAtoms, futureAtoms := PartitionAtomsByTime(atoms)
@@ -865,11 +876,13 @@ func (h *Handler) HandleTabTasks(w http.ResponseWriter, r *http.Request) {
Atoms []models.Atom
FutureAtoms []models.Atom
Boards []models.Board
+ Chains []models.ChainSummary
Today string
}{
Atoms: currentAtoms,
FutureAtoms: futureAtoms,
Boards: boards,
+ Chains: chainSummaries,
Today: config.Now().Format("2006-01-02"),
}