feat: Add story points support and AI daily briefing feature
- Enhanced JIRA integration to fetch story points from multiple custom fields. - Updated task display to show story points and their estimated duration. - Introduced AI daily briefing banner with dynamic content loading. - Implemented subtasks functionality with add, toggle, and delete capabilities. - Improved task management UI with better accessibility and interaction.
This commit is contained in:
+114
@@ -486,6 +486,120 @@ try {
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- V2.0: Subtaken & Checklists ---
|
||||
|
||||
// 7. Subtaak toevoegen aan een taak
|
||||
if ($action === 'add_subtask') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$taskId = (int)($data['task_id'] ?? 0);
|
||||
$title = trim($data['title'] ?? '');
|
||||
|
||||
if (!$taskId || empty($title)) {
|
||||
echo json_encode(['error' => 'Taak-ID en titel zijn verplicht']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Controleer of de taak van deze gebruiker is
|
||||
$stmtCheck = $db->prepare("SELECT id FROM tasks WHERE id = ? AND user_id = ?");
|
||||
$stmtCheck->execute([$taskId, $user['id']]);
|
||||
if (!$stmtCheck->fetchColumn()) {
|
||||
echo json_encode(['error' => 'Taak niet gevonden']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Bereken positie (achteraan)
|
||||
$stmtPos = $db->prepare("SELECT COALESCE(MAX(position), -1) + 1 FROM task_subtasks WHERE task_id = ?");
|
||||
$stmtPos->execute([$taskId]);
|
||||
$position = (int)$stmtPos->fetchColumn();
|
||||
|
||||
$stmt = $db->prepare("
|
||||
INSERT INTO task_subtasks (task_id, user_id, title, is_completed, position)
|
||||
VALUES (?, ?, ?, 0, ?)
|
||||
");
|
||||
$stmt->execute([$taskId, $user['id'], substr($title, 0, 255), $position]);
|
||||
$subtaskId = (int)$db->lastInsertId();
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'subtask' => [
|
||||
'id' => $subtaskId,
|
||||
'task_id' => $taskId,
|
||||
'title' => $title,
|
||||
'is_completed' => 0,
|
||||
'position' => $position,
|
||||
]
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 8. Subtaak afvinken / openzetten
|
||||
if ($action === 'toggle_subtask') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$subtaskId = (int)($data['subtask_id'] ?? 0);
|
||||
$isCompleted = !empty($data['is_completed']) ? 1 : 0;
|
||||
|
||||
if (!$subtaskId) {
|
||||
echo json_encode(['error' => 'Subtaak-ID ontbreekt']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("
|
||||
UPDATE task_subtasks SET is_completed = ?
|
||||
WHERE id = ? AND user_id = ?
|
||||
");
|
||||
$stmt->execute([$isCompleted, $subtaskId, $user['id']]);
|
||||
|
||||
echo json_encode(['success' => true, 'is_completed' => $isCompleted]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 9. Subtaak verwijderen
|
||||
if ($action === 'delete_subtask') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$subtaskId = (int)($data['subtask_id'] ?? 0);
|
||||
|
||||
if (!$subtaskId) {
|
||||
echo json_encode(['error' => 'Subtaak-ID ontbreekt']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("DELETE FROM task_subtasks WHERE id = ? AND user_id = ?");
|
||||
$stmt->execute([$subtaskId, $user['id']]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 10. Subtaken ophalen voor een taak
|
||||
if ($action === 'get_subtasks') {
|
||||
$taskId = (int)($_GET['task_id'] ?? 0);
|
||||
|
||||
if (!$taskId) {
|
||||
echo json_encode(['error' => 'Taak-ID ontbreekt']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Controleer eigenaarschap
|
||||
$stmtCheck = $db->prepare("SELECT id FROM tasks WHERE id = ? AND user_id = ?");
|
||||
$stmtCheck->execute([$taskId, $user['id']]);
|
||||
if (!$stmtCheck->fetchColumn()) {
|
||||
echo json_encode(['error' => 'Taak niet gevonden']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("
|
||||
SELECT id, task_id, title, is_completed, position
|
||||
FROM task_subtasks
|
||||
WHERE task_id = ? AND user_id = ?
|
||||
ORDER BY position ASC, created_at ASC
|
||||
");
|
||||
$stmt->execute([$taskId, $user['id']]);
|
||||
$subtasks = $stmt->fetchAll();
|
||||
|
||||
echo json_encode(['success' => true, 'subtasks' => $subtasks]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['error' => 'Onbekende actie']);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
|
||||
Reference in New Issue
Block a user