Merge tasks into notes: a task is just a note with task attributes
A task is now a note with status/priority/due_date columns set (status IS NOT NULL). This eliminates the separate tasks table, companion note system, cascade deletes, bidirectional title sync, and _skip_cascade flags. Migration (0004): - Add status, priority, due_date columns to notes table - Migrate task data from companion notes and orphan tasks - Drop tasks table and old enum types Backend: - models/note.py: Add TaskStatus/TaskPriority enums, task columns, is_task property - models/task.py: Deleted (merged into note.py) - models/__init__.py: Re-export enums from note.py, remove Task import - services/notes.py: Remove companion/cascade logic, add is_task filter, convert_note_to_task, convert_task_to_note, simplified backlinks - services/tasks.py: Rewritten as thin wrappers around notes service - routes/notes.py: Add is_task filter (default false), task fields in CRUD, convert-to-note endpoint - routes/tasks.py: description→body (with fallback), remove note_id filter Frontend: - types/note.ts: Add TaskStatus, TaskPriority, task fields to Note interface - types/task.ts: Task is now a re-export alias for Note - stores/notes.ts: Simplify convertToTask, add convertToNote - stores/tasks.ts: description→body in createTask/updateTask - TaskEditorView: description→body, remove companion note UI - TaskViewerView: description→body, remove companion note link, add Convert to Note - NoteViewerView: Remove companion task UI, simplify convert-to-task - TaskCard: description→body, non-null assertions for status/priority Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,25 +4,20 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import { useNotesStore } from "@/stores/notes";
|
||||
import { renderMarkdown } from "@/utils/markdown";
|
||||
import { relativeTime } from "@/composables/useRelativeTime";
|
||||
import { apiGet, apiPost } from "@/api/client";
|
||||
import type { Task, TaskListResponse, TaskStatus } from "@/types/task";
|
||||
import { apiPost } from "@/api/client";
|
||||
import type { Note } from "@/types/note";
|
||||
import TagPill from "@/components/TagPill.vue";
|
||||
import StatusBadge from "@/components/StatusBadge.vue";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const store = useNotesStore();
|
||||
const bodyEl = ref<HTMLElement | null>(null);
|
||||
const linkedTasks = ref<Task[]>([]);
|
||||
const backlinks = ref<{ type: string; id: number; title: string }[]>([]);
|
||||
const converting = ref(false);
|
||||
|
||||
const noteId = computed(() => Number(route.params.id));
|
||||
const hasCompanionTask = computed(() => linkedTasks.value.length > 0);
|
||||
|
||||
async function loadNote(id: number) {
|
||||
linkedTasks.value = [];
|
||||
backlinks.value = [];
|
||||
await store.fetchNote(id);
|
||||
|
||||
@@ -32,16 +27,10 @@ async function loadNote(id: number) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch tasks linked to this note & backlinks in parallel
|
||||
const [taskData, backlinkData] = await Promise.allSettled([
|
||||
apiGet<TaskListResponse>(`/api/tasks?note_id=${id}`),
|
||||
store.fetchBacklinks(id),
|
||||
]);
|
||||
if (taskData.status === "fulfilled") {
|
||||
linkedTasks.value = taskData.value.tasks;
|
||||
}
|
||||
if (backlinkData.status === "fulfilled") {
|
||||
backlinks.value = backlinkData.value;
|
||||
try {
|
||||
backlinks.value = await store.fetchBacklinks(id);
|
||||
} catch {
|
||||
backlinks.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,37 +82,14 @@ function onTagClick(tag: string) {
|
||||
router.push({ path: "/notes", query: { tag } });
|
||||
}
|
||||
|
||||
const statusCycle: Record<TaskStatus, TaskStatus> = {
|
||||
todo: "in_progress",
|
||||
in_progress: "done",
|
||||
done: "todo",
|
||||
};
|
||||
|
||||
async function toggleTaskStatus(task: Task) {
|
||||
const newStatus = statusCycle[task.status];
|
||||
try {
|
||||
const { apiPatch } = await import("@/api/client");
|
||||
const updated = await apiPatch<Task>(
|
||||
`/api/tasks/${task.id}/status`,
|
||||
{ status: newStatus }
|
||||
);
|
||||
const idx = linkedTasks.value.findIndex((t) => t.id === task.id);
|
||||
if (idx !== -1) {
|
||||
linkedTasks.value[idx] = updated;
|
||||
}
|
||||
} catch {
|
||||
// silently fail
|
||||
}
|
||||
}
|
||||
|
||||
async function convertToTask() {
|
||||
if (converting.value) return;
|
||||
converting.value = true;
|
||||
try {
|
||||
const task = await store.convertToTask(noteId.value);
|
||||
await store.convertToTask(noteId.value);
|
||||
const { useToastStore } = await import("@/stores/toast");
|
||||
useToastStore().show("Converted to task");
|
||||
router.push(`/tasks/${task.id}`);
|
||||
router.push(`/tasks/${noteId.value}`);
|
||||
} catch {
|
||||
const { useToastStore } = await import("@/stores/toast");
|
||||
useToastStore().show("Failed to convert note", "error");
|
||||
@@ -146,7 +112,7 @@ async function convertToTask() {
|
||||
Edit
|
||||
</router-link>
|
||||
<button
|
||||
v-if="!hasCompanionTask"
|
||||
v-if="!store.currentNote.is_task"
|
||||
class="btn-convert"
|
||||
@click="convertToTask"
|
||||
:disabled="converting"
|
||||
@@ -175,22 +141,6 @@ async function convertToTask() {
|
||||
@click="onBodyClick"
|
||||
></div>
|
||||
|
||||
<div v-if="linkedTasks.length" class="linked-tasks">
|
||||
<h2>Companion Task</h2>
|
||||
<ul class="linked-tasks-list">
|
||||
<li v-for="task in linkedTasks" :key="task.id" class="linked-task-item">
|
||||
<StatusBadge
|
||||
:status="task.status"
|
||||
clickable
|
||||
@click="toggleTaskStatus(task)"
|
||||
/>
|
||||
<router-link :to="`/tasks/${task.id}`" class="linked-task-link">
|
||||
{{ task.title || "Untitled" }}
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="backlinks.length" class="backlinks">
|
||||
<h2>Backlinks</h2>
|
||||
<ul class="backlinks-list">
|
||||
@@ -256,18 +206,15 @@ async function convertToTask() {
|
||||
margin-bottom: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.linked-tasks,
|
||||
.backlinks {
|
||||
margin-top: 2rem;
|
||||
border-top: 1px solid var(--color-border);
|
||||
padding-top: 1rem;
|
||||
}
|
||||
.linked-tasks h2,
|
||||
.backlinks h2 {
|
||||
font-size: 1.1rem;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
.linked-tasks-list,
|
||||
.backlinks-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
@@ -276,19 +223,16 @@ async function convertToTask() {
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.linked-task-item,
|
||||
.backlink-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.linked-task-link,
|
||||
.backlink-link {
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.linked-task-link:hover,
|
||||
.backlink-link:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user