feat: add task sets functionality with CRUD operations and UI integration

- Implemented NewTaskSetPage for creating task sets with templates.
- Created TaskSetsPage for listing and filtering task sets.
- Enhanced TaskTemplatesPage with navigation to task sets.
- Updated ProjectTaskForm to support task set selection.
- Modified PageHeader to support multiple action buttons.
- Initialized database with task_sets and task_set_templates tables.
- Added queries for task sets including creation, retrieval, and deletion.
- Implemented applyTaskSetToProject function for bulk task creation.
- Added test script for verifying task sets functionality.
This commit is contained in:
2025-10-07 21:58:08 +02:00
parent e19172d2bb
commit 952caf10d1
14 changed files with 1838 additions and 77 deletions

View File

@@ -41,7 +41,29 @@ export default function initializeDatabase() {
name TEXT NOT NULL,
max_wait_days INTEGER DEFAULT 0,
is_standard INTEGER NOT NULL DEFAULT 0
); -- Table: project_tasks
);
-- Table: task_sets
CREATE TABLE IF NOT EXISTS task_sets (
set_id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
description TEXT,
task_category TEXT CHECK(task_category IN ('design', 'construction')) NOT NULL,
created_at TEXT DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT DEFAULT CURRENT_TIMESTAMP
);
-- Table: task_set_templates
CREATE TABLE IF NOT EXISTS task_set_templates (
set_id INTEGER NOT NULL,
task_template_id INTEGER NOT NULL,
sort_order INTEGER DEFAULT 0,
PRIMARY KEY (set_id, task_template_id),
FOREIGN KEY (set_id) REFERENCES task_sets(set_id) ON DELETE CASCADE,
FOREIGN KEY (task_template_id) REFERENCES tasks(task_id)
);
-- Table: project_tasks
CREATE TABLE IF NOT EXISTS project_tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
project_id INTEGER NOT NULL,
@@ -342,6 +364,24 @@ export default function initializeDatabase() {
console.warn("Migration warning:", e.message);
}
// Migration: Rename project_type to task_category in task_sets
try {
// Check if the old column exists and rename it
const tableInfo = db.prepare("PRAGMA table_info(task_sets)").all();
const hasOldColumn = tableInfo.some(col => col.name === 'project_type');
const hasNewColumn = tableInfo.some(col => col.name === 'task_category');
if (hasOldColumn && !hasNewColumn) {
// Rename the column
db.exec(`
ALTER TABLE task_sets RENAME COLUMN project_type TO task_category;
`);
console.log("✅ Renamed project_type to task_category in task_sets");
}
} catch (e) {
console.warn("Migration warning:", e.message);
}
// Generic file attachments table
db.exec(`
CREATE TABLE IF NOT EXISTS file_attachments (