64bc50c788
Drift-audit Group 7 frontend cleanup (no behavioral change): - SettingsView: remove the 'auto-consolidate task bodies' toggle and its saveAutoConsolidate handler. The auto_consolidate_tasks setting has zero backend readers (curator removed in Phase 8); the control did nothing. - AppSettings type: drop the dead assistant_name / default_model hints (kept the open string index signature the store actually uses). Delete the fully orphaned types/chat.ts (zero importers). - notes/tasks Pinia stores: remove the list/filter/sort/pagination surface that backed the removed /notes and /tasks list views (verified no consumer uses the tasks/notes arrays, refresh, or any filter/sort/pagination method). Kept currentNote/currentTask, loading, fetch/create/update/delete, convert, patchStatus, startPlanning, backlinks, tags. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
115 lines
3.1 KiB
TypeScript
115 lines
3.1 KiB
TypeScript
import { ref } from "vue";
|
|
import { defineStore } from "pinia";
|
|
import { apiGet, apiPost, apiPut, apiPatch, apiDelete } from "@/api/client";
|
|
import { useToastStore } from "@/stores/toast";
|
|
import type { Task, TaskStatus, TaskPriority, StartPlanningResult } from "@/types/task";
|
|
|
|
// Single-task + mutation surface. The list/filter/sort/pagination surface that
|
|
// backed the removed /tasks list view was dropped in the 2026-06-02 drift-audit
|
|
// cleanup (no consumers — ProjectView's kanban keeps its own local task list).
|
|
export const useTasksStore = defineStore("tasks", () => {
|
|
const currentTask = ref<Task | null>(null);
|
|
const loading = ref(false);
|
|
|
|
async function fetchTask(id: number) {
|
|
loading.value = true;
|
|
try {
|
|
currentTask.value = await apiGet<Task>(`/api/tasks/${id}`);
|
|
} catch (e) {
|
|
useToastStore().show("Failed to load task", "error");
|
|
throw e;
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
async function createTask(data: {
|
|
title: string;
|
|
body: string;
|
|
tags?: string[];
|
|
status?: TaskStatus;
|
|
priority?: TaskPriority;
|
|
due_date?: string | null;
|
|
project_id?: number | null;
|
|
milestone_id?: number | null;
|
|
parent_id?: number | null;
|
|
recurrence_rule?: Record<string, unknown> | null;
|
|
}): Promise<Task> {
|
|
try {
|
|
return await apiPost<Task>("/api/tasks", data);
|
|
} catch (e) {
|
|
useToastStore().show("Failed to create task", "error");
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
async function updateTask(
|
|
id: number,
|
|
data: Partial<
|
|
Pick<Task, "title" | "body" | "tags" | "status" | "priority" | "due_date" | "project_id" | "milestone_id" | "parent_id" | "recurrence_rule">
|
|
>
|
|
): Promise<Task> {
|
|
try {
|
|
const task = await apiPut<Task>(`/api/tasks/${id}`, data);
|
|
if (currentTask.value?.id === id) {
|
|
currentTask.value = task;
|
|
}
|
|
return task;
|
|
} catch (e) {
|
|
useToastStore().show("Failed to update task", "error");
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
async function patchStatus(id: number, status: TaskStatus): Promise<Task> {
|
|
try {
|
|
const task = await apiPatch<Task>(`/api/tasks/${id}/status`, { status });
|
|
if (currentTask.value?.id === id) {
|
|
currentTask.value = task;
|
|
}
|
|
return task;
|
|
} catch (e) {
|
|
useToastStore().show("Failed to update task status", "error");
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
async function deleteTask(id: number) {
|
|
try {
|
|
await apiDelete(`/api/tasks/${id}`);
|
|
if (currentTask.value?.id === id) {
|
|
currentTask.value = null;
|
|
}
|
|
} catch (e) {
|
|
useToastStore().show("Failed to delete task", "error");
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
async function startPlanning(
|
|
projectId: number,
|
|
title: string
|
|
): Promise<StartPlanningResult> {
|
|
try {
|
|
return await apiPost<StartPlanningResult>("/api/tasks/planning", {
|
|
project_id: projectId,
|
|
title,
|
|
});
|
|
} catch (e) {
|
|
useToastStore().show("Failed to start planning", "error");
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
return {
|
|
currentTask,
|
|
loading,
|
|
fetchTask,
|
|
createTask,
|
|
updateTask,
|
|
patchStatus,
|
|
deleteTask,
|
|
startPlanning,
|
|
};
|
|
});
|