Files
2022-09-02 22:40:21 +02:00

39 lines
1.2 KiB
Haskell

module Web.View.Entries.Index where
import Web.View.Prelude
data IndexView = IndexView { entries :: [Entry] }
instance View IndexView where
html IndexView { .. } = [hsx|
{breadcrumb}
<h1>Index<a href={pathTo NewEntryAction} class="btn btn-primary ml-4">+ New</a></h1>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Entry</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>{forEach entries renderEntry}</tbody>
</table>
</div>
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "Entries" EntriesAction
]
renderEntry :: Entry -> Html
renderEntry entry = [hsx|
<tr>
<td>{entry}</td>
<td><a href={ShowEntryAction entry.id}>Show</a></td>
<td><a href={EditEntryAction entry.id} class="text-muted">Edit</a></td>
<td><a href={DeleteEntryAction entry.id} class="js-delete text-muted">Delete</a></td>
</tr>
|]