fix(webui): derive the task filter through a function the guard can call
This commit is contained in:
1 parent
4720757cd9
commit
429351bec6
4 files changed
+44
-13
No files matched your search
@@ -22,7 +22,7 @@ import { api } from "@/lib/api";
|
||||
import { statusList } from "@/lib/task-meta";
|
||||
import { useLiveResource } from "@/stores/live-updates";
|
||||
import TaskFilters from "./TaskFilters.vue";
|
||||
import { initialTaskFilter, taskMatchesStatus } from "./task-filter";
|
||||
import { boardStatus, initialTaskFilter, taskMatchesStatus } from "./task-filter";
|
||||
import type { Task } from "./TaskRow.vue";
|
||||
import TaskTable from "./TaskTable.vue";
|
||||
import TasksState from "./TasksState.vue";
|
||||
@@ -52,10 +52,11 @@ const requestedTaskId = computed(() => {
|
||||
|
||||
// The filter follows the URL as well as writing to it: a dashboard link or a
|
||||
// back-button step has to move the control, not just load the page behind it.
|
||||
// It is derived from the query rather than captured from it, because the
|
||||
// served catalog lands after this page sets up -- a drop to the freeze-dried
|
||||
// defaults here would drop a shared link to a status the server serves.
|
||||
const status = computed(() => initialTaskFilter(statusQuery.value, statusList()));
|
||||
// It is derived rather than captured, and the catalog is read inside the
|
||||
// computed: the served catalog lands after this page sets up, so a drop to the
|
||||
// freeze-dried defaults here would drop a shared link to a status the server
|
||||
// serves.
|
||||
const status = computed(() => boardStatus(statusQuery.value, statusList()));
|
||||
|
||||
const visible = computed(() =>
|
||||
(tasks.value ?? []).filter((task) => {
|
||||
|
||||
@@ -6,6 +6,14 @@
|
||||
// is no way to test that capture without being able to replace the catalog.
|
||||
// A caller that passes the catalog from inside a `computed` re-derives when
|
||||
// `/api/task-meta` lands.
|
||||
//
|
||||
// Only type imports, and only from "@/": `node --test` runs this file with
|
||||
// --experimental-strip-types and resolves no tsconfig paths, so `import type`
|
||||
// is erased before node ever sees the specifier. A value import from
|
||||
// "@/lib/..." would kill the suite with ERR_MODULE_NOT_FOUND that names
|
||||
// nothing in this package, so a value that has to cross this boundary is
|
||||
// either an argument (the catalog, below) or a relative specifier with its
|
||||
// .ts extension.
|
||||
import type { StatusMeta } from "@/lib/task-meta";
|
||||
|
||||
// The vocabulary is the server catalog, not a hand-synced copy: the set of
|
||||
@@ -26,6 +34,20 @@ export function initialTaskFilter(requested: string | null | undefined, catalog:
|
||||
return requested && taskStatuses(catalog).has(requested) ? requested : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* boardStatus is the task board's status filter: what the control shows and
|
||||
* what the table filters by, for one query value and the catalog read at the
|
||||
* moment of the call. It exists as a named derivation so the page's only
|
||||
* remaining decision is where each argument comes from -- and the catalog has
|
||||
* to be read inside the `computed`, because a caller that evaluates
|
||||
* `statusList()` while the page sets up passes the freeze-dried defaults for
|
||||
* the life of the page, which is how a shared link to a served-only status
|
||||
* filtered nothing until a reload.
|
||||
*/
|
||||
export function boardStatus(query: string, catalog: StatusMeta[]): string {
|
||||
return initialTaskFilter(query, catalog);
|
||||
}
|
||||
|
||||
/** taskMatchesStatus reports whether a task survives the status filter. */
|
||||
export function taskMatchesStatus(
|
||||
task: { status?: string },
|
||||
|
||||
Reference in new issue
Block a user