A To do card on server pages and in a device's drawer
- The open jobs about a server (or device) are listed on its page, with a line to add another already about it and a box to tick one off with Undo - GET /api/todos takes ?targetType=&targetId= to list only those about one thing - README and ROLES updated Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
18ceed62e8
commit
788b3e073c
10 files changed
+164
-9
No files matched your search
@@ -68,10 +68,11 @@ async function shape(rows: Row[]): Promise<TodoItem[]> {
|
||||
}
|
||||
|
||||
/** Open ones first, the soonest due first (those with no day last); done ones after, the latest done first. */
|
||||
export async function listTodos(): Promise<TodoItem[]> {
|
||||
const open = await shape(await db.select().from(todos).where(isNull(todos.doneAt)));
|
||||
export async function listTodos(about?: { type: TargetType; id: number }): Promise<TodoItem[]> {
|
||||
const only = about ? and(eq(todos.targetType, about.type), eq(todos.targetId, about.id)) : undefined;
|
||||
const open = await shape(await db.select().from(todos).where(and(isNull(todos.doneAt), only)));
|
||||
open.sort((a, b) => (a.dueDate ?? "9999-99-99").localeCompare(b.dueDate ?? "9999-99-99") || a.createdAt.localeCompare(b.createdAt) || a.id - b.id);
|
||||
const done = await shape(await db.select().from(todos).where(isNotNull(todos.doneAt)).orderBy(desc(todos.doneAt)).limit(200));
|
||||
const done = await shape(await db.select().from(todos).where(and(isNotNull(todos.doneAt), only)).orderBy(desc(todos.doneAt)).limit(200));
|
||||
return [...open, ...done];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user