diff --git a/static/css/tasks.css b/static/css/tasks.css index 41026a2..a40bbdb 100644 --- a/static/css/tasks.css +++ b/static/css/tasks.css @@ -97,6 +97,72 @@ border-color: #28a745; } +.status-toggle { + display: flex; + gap: 0.5rem; + flex-wrap: wrap; +} + +.status-btn { + padding: 0.5rem 1rem; + border: 2px solid #ddd; + border-radius: 6px; + cursor: pointer; + font-size: 0.875rem; + font-weight: 500; + transition: all 0.15s ease; + background: #f8f9fa; + color: #666; +} + +.status-btn.todo:hover { + border-color: #667eea; + color: #667eea; +} + +.status-btn.todo.active { + background: #f8f9fa; + border-color: #667eea; + color: #667eea; + box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2); +} + +.status-btn.doing:hover { + border-color: #ffc107; + color: #b8860b; +} + +.status-btn.doing.active { + background: #fff3cd; + border-color: #ffc107; + color: #856404; + box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.2); +} + +.status-btn.pending:hover { + border-color: #2196F3; + color: #2196F3; +} + +.status-btn.pending.active { + background: #e7f3ff; + border-color: #2196F3; + color: #0d6efd; + box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2); +} + +.status-btn.done:hover { + border-color: #28a745; + color: #28a745; +} + +.status-btn.done.active { + background: #d4edda; + border-color: #28a745; + color: #155724; + box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2); +} + .task-item:hover { background: #e9ecef; } diff --git a/static/js/tasks.js b/static/js/tasks.js index 8150f84..6b6f0fc 100644 --- a/static/js/tasks.js +++ b/static/js/tasks.js @@ -234,9 +234,12 @@ function selectTask(taskId) { document.getElementById("edit-task-title").value = task.title; document.getElementById("edit-task-desc").value = task.desc || ""; - document.getElementById("edit-task-status").value = task.status; document.getElementById("side-panel-error").textContent = ""; + document.querySelectorAll(".status-btn").forEach(btn => { + btn.classList.toggle("active", btn.dataset.status === task.status); + }); + const sidePanel = document.getElementById("side-panel"); if (!sidePanel.classList.contains("active")) { sidePanel.classList.add("active"); @@ -257,7 +260,6 @@ async function saveTask() { const title = document.getElementById("edit-task-title").value.trim(); const desc = document.getElementById("edit-task-desc").value; - const status = document.getElementById("edit-task-status").value; if (!title) { error.textContent = "Title is required"; @@ -266,12 +268,24 @@ async function saveTask() { try { await put(`/api/tasks/${selectedTaskId}`, { title, desc }); + await loadTasks(); + } catch (err) { + error.textContent = err.message; + } +} - const currentTask = tasks.find(t => t.id === selectedTaskId); - if (status !== currentTask?.status) { - await patch(`/api/tasks/${selectedTaskId}/status`, { status }); - } +async function setTaskStatus(status) { + if (!selectedTaskId) return; + const error = document.getElementById("side-panel-error"); + error.textContent = ""; + + document.querySelectorAll(".status-btn").forEach(btn => { + btn.classList.toggle("active", btn.dataset.status === status); + }); + + try { + await patch(`/api/tasks/${selectedTaskId}/status`, { status }); await loadTasks(); } catch (err) { error.textContent = err.message; diff --git a/templates/tasks.html b/templates/tasks.html index 60609e9..d4b53ab 100644 --- a/templates/tasks.html +++ b/templates/tasks.html @@ -39,13 +39,13 @@
- - + +
+ + + + +