Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F969693
tasks-view.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
tasks-view.ts
View Options
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
Details
Attached
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)
Attached To
Mode
rPLAY Sealious playground
Attached
Detach File
Event Timeline
Log In to Comment