diff --git a/static/js/storage.js b/static/js/storage.js index 4fb648b..6987eff 100644 --- a/static/js/storage.js +++ b/static/js/storage.js @@ -1504,19 +1504,13 @@ const todos = await getAllFromStore(STORES.TODOS); return todos.sort((a, b) => { if (a.status !== b.status) return a.status === 'pending' ? -1 : 1; - const now = new Date().toISOString().slice(0, 10); - const aOverdue = a.due_date && a.due_date < now && a.status === 'pending'; - const bOverdue = b.due_date && b.due_date < now && b.status === 'pending'; - if (aOverdue !== bOverdue) return aOverdue ? -1 : 1; - const priOrder = { high: 0, medium: 1, low: 2, none: 3 }; - const aPri = priOrder[a.priority] ?? 3; - const bPri = priOrder[b.priority] ?? 3; - if (aPri !== bPri) return aPri - bPri; - return new Date(a.created_at) - new Date(b.created_at); + return (a.sort_order ?? 999999) - (b.sort_order ?? 999999); }); }, createTodo: async function(data) { + const existing = await getAllFromStore(STORES.TODOS); + const maxOrder = existing.reduce((m, t) => Math.max(m, t.sort_order ?? 0), 0); const todo = { id: generateUUID(), title: data.title || '', @@ -1525,6 +1519,7 @@ priority: data.priority || 'none', due_date: data.due_date || null, list_id: data.list_id || null, + sort_order: maxOrder + 1, created_at: new Date().toISOString(), completed_at: null }; diff --git a/templates/index.html b/templates/index.html index fca8cbd..46ec22d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -249,11 +249,12 @@ .todo-lists-bar { display: flex; gap: 0.5rem; background: var(--bg-secondary); padding: 0.25rem; border-radius: 8px; margin-bottom: 1rem; flex-wrap: wrap; + justify-content: center; } .todo-lists-bar button { - padding: 0.5rem 1rem; background: transparent; border: none; + flex: 1 1 auto; padding: 0.5rem 1rem; background: transparent; border: none; color: var(--text-secondary); cursor: pointer; border-radius: 6px; font-size: 0.875rem; - white-space: nowrap; + white-space: nowrap; text-align: center; } .todo-lists-bar button:hover { background: var(--bg-tertiary); color: var(--text-primary); } .todo-lists-bar button.active { background: var(--bg-tertiary); color: var(--text-primary); font-weight: 600; } @@ -290,11 +291,10 @@ cursor: pointer; padding: 0.25rem 0.5rem; font-size: 1rem; } .todo-actions button:hover { color: var(--text-primary); } - .todo-add-form { - display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; + .todo-toolbar { + display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; } - .todo-add-form input[type="text"] { flex: 1; min-width: 200px; } - .todo-add-form select, .todo-add-form input[type="date"] { max-width: 150px; } + .todo-toolbar select { font-size: 0.875rem; padding: 0.5rem; max-width: 170px; } .todo-completed-header { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; color: var(--text-secondary); margin-top: 1.5rem; margin-bottom: 0.5rem; @@ -742,19 +742,16 @@