summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-01-27 07:02:33 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-01-27 07:02:33 -1000
commit59c360c3c33a55447f08e95fed4714959300850c (patch)
treebdcd7fa0f98fa8ab874e63f888d7dc5528aee763 /internal
parentf8757aef930a22669255359ff50908e0f7a941af (diff)
Fix z-index, conditions auth, and meal combining (#62, #63, #64)
Bug fixes: - #62: Increase FAB button z-index from z-40 to z-50 - #63: Combine multiple meals per date+mealType in Meals tab - #64: Make /conditions route public (no auth required) Changes: - FAB button now z-50 (same as modals, appears on top when scrolling) - Meals tab groups meals by date+mealType, joins recipe names with " + " - Conditions page moved outside protected routes group DESIGN.md updates: - Updated z-index hierarchy table - Added Meals View section - Noted conditions page is public Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/handlers/handlers.go63
1 files changed, 62 insertions, 1 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go
index 1c2eb18..9fe1b2c 100644
--- a/internal/handlers/handlers.go
+++ b/internal/handlers/handlers.go
@@ -1139,6 +1139,14 @@ func (h *Handler) HandleTabPlanning(w http.ResponseWriter, r *http.Request) {
HTMLResponse(w, h.templates, "planning-tab", data)
}
+// CombinedMeal represents multiple meals combined for same date+mealType
+type CombinedMeal struct {
+ RecipeNames []string
+ Date time.Time
+ MealType string
+ RecipeURL string // URL of first meal
+}
+
// HandleTabMeals renders the Meals tab (PlanToEat)
func (h *Handler) HandleTabMeals(w http.ResponseWriter, r *http.Request) {
startDate := config.Now()
@@ -1150,7 +1158,60 @@ func (h *Handler) HandleTabMeals(w http.ResponseWriter, r *http.Request) {
return
}
- HTMLResponse(w, h.templates, "meals-tab", struct{ Meals []models.Meal }{meals})
+ // Group meals by date+mealType
+ type mealKey struct {
+ date string
+ mealType string
+ }
+ mealGroups := make(map[mealKey][]models.Meal)
+ for _, meal := range meals {
+ key := mealKey{
+ date: meal.Date.Format("2006-01-02"),
+ mealType: meal.MealType,
+ }
+ mealGroups[key] = append(mealGroups[key], meal)
+ }
+
+ // Convert to combined meals
+ var combined []CombinedMeal
+ for _, group := range mealGroups {
+ if len(group) == 0 {
+ continue
+ }
+ cm := CombinedMeal{
+ Date: group[0].Date,
+ MealType: group[0].MealType,
+ RecipeURL: group[0].RecipeURL,
+ }
+ for _, m := range group {
+ cm.RecipeNames = append(cm.RecipeNames, m.RecipeName)
+ }
+ combined = append(combined, cm)
+ }
+
+ // Sort by date then meal type order
+ sort.Slice(combined, func(i, j int) bool {
+ if !combined[i].Date.Equal(combined[j].Date) {
+ return combined[i].Date.Before(combined[j].Date)
+ }
+ return mealTypeOrder(combined[i].MealType) < mealTypeOrder(combined[j].MealType)
+ })
+
+ HTMLResponse(w, h.templates, "meals-tab", struct{ Meals []CombinedMeal }{combined})
+}
+
+// mealTypeOrder returns sort order for meal types
+func mealTypeOrder(mealType string) int {
+ switch mealType {
+ case "breakfast":
+ return 0
+ case "lunch":
+ return 1
+ case "dinner":
+ return 2
+ default:
+ return 3
+ }
}
// HandleTabShopping renders the Shopping tab (Trello Shopping board + PlanToEat + User items)