Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F996344
tasks.views.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.views.ts
View Options
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import
{
CollectionItem
,
Context
}
from
"sealious"
;
import
frame
from
"../../frame"
;
export
function
Task
(
task
:
CollectionItem
<
never
>
)
:
string
{
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"
:
""
}
/>
${
task
.
get
(
"title"
)
}
<form method="DELETE" action="/tasks/
${
task
.
id
}
" data-turbo-frame="task-list">
<input class="delete-button" type="submit" value="🗑" />
</form>
</li>`
);
}
export
async
function
TaskList
(
context
:
Context
)
:
Promise
<
string
>
{
const
{
items
:
tasks
}
=
await
context
.
app
.
collections
.
tasks
.
list
(
context
).
fetch
();
return
frame
(
"task-list"
,
/* HTML */
`
<ul>
${
tasks
.
map
(
Task
).
join
(
"\n"
)
}
</ul>
`
);
}
export
function
NewTask
()
:
string
{
return
frame
(
"new-task"
,
/* HTML */
`<form method="POST" action="/tasks" data-turbo-frame="task-list">
<input
id="new-task-title"
type="text"
placeholder="write an app"
name="title"
/>
<input type="submit" value="Add" />
</form>`
);
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Tue, Dec 24, 14:02 (21 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557194
Default Alt Text
tasks.views.ts (1 KB)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline
Log In to Comment