From d2a9c79633b73be62ed75442c94adb304cc54f2e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 5 Nov 2025 13:21:04 +0000 Subject: [PATCH] Add inline context creation when creating todos Users can now create a new context directly from the todo creation modal without having to navigate away to the contexts page. Changes: - Added "Create new context..." option to context dropdown in todo modal - Added inline form that appears when user selects "Create new context" - Added JavaScript to show/hide the new context input field dynamically - Added form validation to ensure either an existing context is selected or a new context name is provided - Updated HandleCreateTodo to detect when user wants to create a new context (context_id == "__new__") and create it before creating the todo - New contexts are created with proper position ordering UX Flow: 1. User clicks "New Todo" 2. User selects "Create new context..." from dropdown 3. Input field appears below for entering context name 4. User enters context name (e.g., "@home", "@work") 5. When form is submitted, context is created first, then todo is created with the new context automatically assigned 6. User is redirected back to todos page with both new context and todo visible This streamlines the workflow and eliminates context switching when users need to quickly add a todo with a new context. --- cmd/tracks/web/templates/todos.html | 56 ++++++++++++++++++++++--- internal/handlers/web_handler.go | 63 ++++++++++++++++++++++------- 2 files changed, 99 insertions(+), 20 deletions(-) diff --git a/cmd/tracks/web/templates/todos.html b/cmd/tracks/web/templates/todos.html index d35fce2b..5aa1ea02 100644 --- a/cmd/tracks/web/templates/todos.html +++ b/cmd/tracks/web/templates/todos.html @@ -182,15 +182,19 @@
- + {{range .Contexts}} {{end}} + - {{if not .Contexts}} - You need to create a context first before creating todos. - {{end}} +
+ +
@@ -214,12 +218,54 @@