Page MenuHomeSealhub

tasks-view.ts
No OneTemporary

tasks-view.ts

import { BaseContext } from "koa";
import { CollectionItem } from "sealious";
import frame from "../../frame.js";
import { Tasks } from "../../collections/collections.js";
export function Task(task: CollectionItem<typeof Tasks>) {
const title = task.get("title");
const title_string = title ? title : "";
return frame(
`task-${task.id}`,
/* HTML */ `<li class="task">
<input
type="checkbox"
data-controller="task"
data-action="task#toggle"
data-id="${task.id}"
${task.get("done") ? "checked" : ""}
/>
${title_string}
<form method="POST" action="/todo/">
<input class="delete-button" type="submit" value="Delete" />
<input
class="hidden-button"
type="hidden"
name="taskId"
value="${task.id}"
/>
<input
class="hidden-button"
type="hidden"
id="action"
name="action"
value="delete"
/>
</form>
</li>`
);
}
/*
<form method="DELETE" action="/todo/${task.id}">
<input class="delete-button" type="submit" value="Delete" />
</form>
*/
export async function TaskList(ctx: BaseContext) {
const { items: tasks } = await ctx.$app.collections.tasks.list(ctx.$context).fetch();
const tasksTemplate = tasks.map(Task).join("\n");
return `
<ul>
${tasksTemplate}
</ul>
`;
}

File Metadata

Mime Type
text/x-java
Expires
Sat, Nov 23, 10:44 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547971
Default Alt Text
tasks-view.ts (1 KB)

Event Timeline