From 4c29151f7c645e6aa23a062e4c470daa63d88644 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 13 Jun 2026 21:48:44 +0200 Subject: [PATCH] feat(todo): add exclusive open/done status filter --- src/views/TodoNotes.vue | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/views/TodoNotes.vue b/src/views/TodoNotes.vue index e599f43..25681ef 100644 --- a/src/views/TodoNotes.vue +++ b/src/views/TodoNotes.vue @@ -107,6 +107,13 @@ const activeProjects = ref>(new Set()) const activeContexts = ref>(new Set()) const activePriorities = ref>(new Set()) +// XOR: either "open" only, "done" only, or "all" (no status filter). +type StatusFilter = "all" | "open" | "done" +const statusFilter = ref("all") +const setStatusFilter = (next: Exclude) => { + statusFilter.value = statusFilter.value === next ? "all" : next +} + const toggleProject = (p: string) => { const next = new Set(activeProjects.value) if (next.has(p)) next.delete(p) @@ -132,13 +139,15 @@ const clearFilters = () => { activeProjects.value = new Set() activeContexts.value = new Set() activePriorities.value = new Set() + statusFilter.value = "all" } const hasFilters = computed( () => activeProjects.value.size > 0 || activeContexts.value.size > 0 || - activePriorities.value.size > 0 + activePriorities.value.size > 0 || + statusFilter.value !== "all" ) const priorityBadgeFilterClass = (p: string | "none"): string => { @@ -168,7 +177,10 @@ const filteredEntries = computed(() => { const prioritiesOk = activePriorities.value.size === 0 || activePriorities.value.has(line.priority ?? "none") - return projectsOk && contextsOk && prioritiesOk + const statusOk = + statusFilter.value === "all" || + (statusFilter.value === "done" ? line.completed : !line.completed) + return projectsOk && contextsOk && prioritiesOk && statusOk }) }) @@ -277,6 +289,27 @@ const createTodoFile = async () => { class="todo-filters" >
+
+

Status

+
+ + +
+