Initial project setup

This commit is contained in:
Arne Weiss
2022-09-02 22:40:21 +02:00
commit ce35c0300c
41 changed files with 1127 additions and 0 deletions

26
Web/View/Entries/Edit.hs Normal file
View File

@@ -0,0 +1,26 @@
module Web.View.Entries.Edit where
import Web.View.Prelude
data EditView = EditView { entry :: Entry }
instance View EditView where
html EditView { .. } = [hsx|
{breadcrumb}
<h1>Edit Entry</h1>
{renderForm entry}
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "Entries" EntriesAction
, breadcrumbText "Edit Entry"
]
renderForm :: Entry -> Html
renderForm entry = formFor entry [hsx|
{(textField #till)}
{(textField #day)}
{(textField #comment)}
{(textField #isfree)}
{submitButton}
|]

39
Web/View/Entries/Index.hs Normal file
View File

@@ -0,0 +1,39 @@
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>
|]

26
Web/View/Entries/New.hs Normal file
View File

@@ -0,0 +1,26 @@
module Web.View.Entries.New where
import Web.View.Prelude
data NewView = NewView { entry :: Entry }
instance View NewView where
html NewView { .. } = [hsx|
{breadcrumb}
<h1>New Entry</h1>
{renderForm entry}
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "Entries" EntriesAction
, breadcrumbText "New Entry"
]
renderForm :: Entry -> Html
renderForm entry = formFor entry [hsx|
{(textField #till)}
{(textField #day)}
{(textField #comment)}
{(textField #isfree)}
{submitButton}
|]

17
Web/View/Entries/Show.hs Normal file
View File

@@ -0,0 +1,17 @@
module Web.View.Entries.Show where
import Web.View.Prelude
data ShowView = ShowView { entry :: Entry }
instance View ShowView where
html ShowView { .. } = [hsx|
{breadcrumb}
<h1>Show Entry</h1>
<p>{entry}</p>
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "Entries" EntriesAction
, breadcrumbText "Show Entry"
]

19
Web/View/Entries/Today.hs Normal file
View File

@@ -0,0 +1,19 @@
module Web.View.Entries.Today where
import Web.View.Prelude
data TodayView = TodayView { entries :: [Entry] }
instance View TodayView where
html TodayView { .. } = [hsx|
{breadcrumb}
<h1>TodayView</h1>
<button id="today-button" style="width:800px; height:600px">
<input type="image" src="/time_on.svg" width="100%" height="100%" />
</button>
<div>0H 0:00H</div>
|]
where
breadcrumb = renderBreadcrumb
[ breadcrumbLink "Todays" EntriesAction
, breadcrumbText "TodayView"
]