Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F969369
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
type
{
BaseContext
}
from
"koa"
;
import
type
{
CollectionItem
}
from
"sealious"
;
import
frame
from
"../../frame.js"
;
import
type
{
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
Fri, Nov 22, 20:17 (1 d, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547747
Default Alt Text
tasks-view.ts (1 KB)
Attached To
Mode
rPLAY Sealious playground
Attached
Detach File
Event Timeline
Log In to Comment