From 1288fe1cf835ac05b94d61212acc74ab87869f53 Mon Sep 17 00:00:00 2001 From: RKWojs Date: Thu, 9 Oct 2025 12:39:43 +0200 Subject: [PATCH] feat: add 'not_started' task status with updates to task creation, status handling, and translations --- src/components/ProjectTasksSection.js | 23 +++++++++++------------ src/lib/init-db.js | 22 ++++++++++++---------- src/lib/queries/tasks.js | 8 ++++---- src/lib/serverTranslations.js | 2 ++ 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/components/ProjectTasksSection.js b/src/components/ProjectTasksSection.js index 646450c..75cca3c 100644 --- a/src/components/ProjectTasksSection.js +++ b/src/components/ProjectTasksSection.js @@ -840,19 +840,18 @@ export default function ProjectTasksSection({ projectId }) { ...prev, status: e.target.value, })) - } - className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" - > - - - - - - - + } + className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500" + > + + + + + + + - -
+
diff --git a/src/lib/init-db.js b/src/lib/init-db.js index c76fcdf..66754fe 100644 --- a/src/lib/init-db.js +++ b/src/lib/init-db.js @@ -280,16 +280,18 @@ export default function initializeDatabase() { } // Migration: Update task status system - add 'not_started' status - try { - // First, update all existing 'pending' tasks to 'not_started' - db.exec(` - UPDATE project_tasks SET status = 'not_started' WHERE status = 'pending'; - `); - // Note: CHECK constraint will be applied when recreating the table in future migrations - // For now, we'll rely on application-level validation - } catch (e) { - // Migration already done, ignore error - } + // DISABLED: This migration was running on every init and converting legitimate + // 'pending' tasks back to 'not_started'. The initial migration has been completed. + // try { + // // First, update all existing 'pending' tasks to 'not_started' + // db.exec(` + // UPDATE project_tasks SET status = 'not_started' WHERE status = 'pending'; + // `); + // // Note: CHECK constraint will be applied when recreating the table in future migrations + // // For now, we'll rely on application-level validation + // } catch (e) { + // // Migration already done, ignore error + // } // Create indexes for notes user tracking try { diff --git a/src/lib/queries/tasks.js b/src/lib/queries/tasks.js index 9a0741f..f1521a4 100644 --- a/src/lib/queries/tasks.js +++ b/src/lib/queries/tasks.js @@ -127,7 +127,7 @@ export function createProjectTask(data) { if (result.lastInsertRowid) { const language = getUserLanguage(); const priority = data.priority || "normal"; - const status = data.status || "pending"; + const status = data.status || "not_started"; const translatedPriority = translatePriority(priority, language); const translatedStatus = translateStatus(status, language); const logMessage = `${serverT("Task created", language)} "${taskName}" ${serverT("with priority", language)}: ${translatedPriority}, ${serverT("status", language)}: ${translatedStatus}`; @@ -158,7 +158,7 @@ export function updateProjectTaskStatus(taskId, status, userId = null) { let stmt; let result; - if (oldStatus === "pending" && status === "in_progress") { + if ((oldStatus === "not_started" || oldStatus === "pending") && status === "in_progress") { // Starting a task - set date_started stmt = db.prepare(` UPDATE project_tasks @@ -334,7 +334,7 @@ export function updateProjectTask(taskId, updates, userId = null) { values.push(updates.status); // Handle status-specific timestamp updates - if (currentTask.status === "pending" && updates.status === "in_progress") { + if ((currentTask.status === "not_started" || currentTask.status === "pending") && updates.status === "in_progress") { fields.push("date_started = datetime('now', 'localtime')"); } else if (updates.status === "completed") { fields.push("date_completed = datetime('now', 'localtime')"); @@ -587,7 +587,7 @@ export function applyTaskSetToProject(setId, projectId, userId = null) { const result = createProjectTask({ project_id: projectId, task_template_id: template.task_id, - status: "pending", + status: "not_started", priority: "normal", created_by: userId, assigned_to: null, // Will be assigned based on user role logic in createProjectTask diff --git a/src/lib/serverTranslations.js b/src/lib/serverTranslations.js index 79ac46c..9ee4844 100644 --- a/src/lib/serverTranslations.js +++ b/src/lib/serverTranslations.js @@ -15,6 +15,7 @@ const serverTranslations = { "with priority": "z priorytetem", "status": "status", "Project cancelled on": "Projekt został wycofany w dniu", + "not_started": "nie rozpoczęte", "pending": "oczekujące", "in_progress": "w trakcie", "completed": "ukończone", @@ -39,6 +40,7 @@ const serverTranslations = { "with priority": "with priority", "status": "status", "Project cancelled on": "Project cancelled on", + "not_started": "not started", "pending": "pending", "in_progress": "in_progress", "completed": "completed",