summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/index.html13
-rw-r--r--templates/parts/entry.html37
-rw-r--r--templates/parts/entryRows.html2
-rw-r--r--templates/parts/taskEntry.html8
-rw-r--r--templates/parts/taskRows.html17
5 files changed, 58 insertions, 19 deletions
diff --git a/templates/index.html b/templates/index.html
index 18ca5f0..99bfc31 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -8,6 +8,7 @@
<!-- TODO REMOVE -->
<script src="https://unpkg.com/htmx.org@1.9.12/dist/htmx.js" integrity="sha384-qbtR4rS9RrUMECUWDWM2+YGgN3U4V4ZncZ0BvUcg9FGct0jqXz3PUdVpU1p0yrXS" crossorigin="anonymous"></script>
+ <script src="https://unpkg.com/htmx.org@1.9.12/dist/ext/response-targets.js"></script>
<style>
.flex {
@@ -73,16 +74,22 @@
padding: 10px;
max-width: 500px;
}
+
+#error-box {
+ color: red;
+ font-weight: bold;
+}
</style>
</head>
- <body>
+ <body hx-ext="response-targets">
<div id="controls-bar">
<button hx-get="/" hx-replace-url="true" hx-params="date" hx-vals='{"date": "{{.DateInfo.Yesterday}}"}' hx-target="body">I går</button>
<input type="date" hx-get="/" hx-replace-url="true" hx-params="date" hx-vals='js:{date: event.target.value}' autocomplete="off" hx-target="body" hx-trigger="change" value="{{.DateInfo.Date}}" />
<button hx-get="/" hx-replace-url="true" hx-params="date" hx-vals='{"date": "{{.DateInfo.Tomorrow}}"}' hx-target="body">I morgen</button>
+ <div id="error-box"></div>
</div>
- <div class="flex">
+ <div class="flex" hx-target-*="#error-box">
<div id="entry-bar">
{{template "entry.html" .Entry}}
<div>
@@ -120,7 +127,7 @@
</select>
</form>
{{ template "task.html" .Task }}
- {{ template "taskRows.html" . }}
+ {{ template "taskRows.html" .Tasks }}
</div>
</div>
</body>
diff --git a/templates/parts/entry.html b/templates/parts/entry.html
index 52f2eb3..4be2073 100644
--- a/templates/parts/entry.html
+++ b/templates/parts/entry.html
@@ -16,17 +16,32 @@
</div>
</div>
<div class="entry-box">
- <b>Mærker</b><br>
- <select>
- <option value="-">-</option>
- <option value="SVT-232">SVT-232</option>
- <option value="Ferie">Ferie</option>
- </select><br>
- <select>
- <option value="-">-</option>
- <option value="SVT-232">SVT-232</option>
- <option value="Ferie">Ferie</option>
- </select>
+ <b>Opgaver</b><br>
+ <input readonly style="display: none;" name="task-count" value="{{ .TaskCount }}" />
+ <table>
+ <tbody>
+ {{ if .Entry }}
+ {{ range $x := taskMapToArr .Entry.Tasks }}
+ <tr>
+ <td>
+ <select name="task-{{$x.Key}}-id" hx-trigger="changedTasks from:body" hx-get="/task/select?selected={{$x.Id}}">
+ {{ template "taskEntry.html" arr $.GroupToTasks $x.Id }}
+ </select>
+ </td>
+ <td><input name="task-{{$x.Key}}-part" type="text" class="short" {{if $x.Sel}}value="{{$x.Sel}}"{{end}}/></td>
+ </tr>
+ {{ end }}
+ {{ end }}
+ <tr>
+ <td>
+ <select name="task-new-id" hx-trigger="changedTasks from:body" hx-get="/task/select">
+ {{ template "taskEntry.html" (arr .GroupToTasks -1) }}
+ </select>
+ </td>
+ <td><input disabled name="task-new-part" type="text" class="short" /></td>
+ </tr>
+ </tbody>
+ </table>
</div>
<div class="entry-box">
<b>Kommentar</b><br>
diff --git a/templates/parts/entryRows.html b/templates/parts/entryRows.html
index 8f10ee3..3749ddb 100644
--- a/templates/parts/entryRows.html
+++ b/templates/parts/entryRows.html
@@ -4,7 +4,7 @@
<td>{{ $entry.Id }}</td>
<td><input type="time" disabled value="{{$entry.From }}" /></td>
<td><input type="time" disabled value="{{if $entry.To}}{{$entry.To }}{{end}}" /></td>
- <td>{{ if $entry.Tag}}{{ $entry.Tag }}{{end}}</td>
+ <td></td>
<td>{{ $entry.Comment }}</td>
<td>
{{ if $entry.To }}<button hx-trigger="click" hx-swap="outerHTML" hx-target="#entry-form" hx-get="/edit?id={{$entry.Id}}">e</button>{{end}}
diff --git a/templates/parts/taskEntry.html b/templates/parts/taskEntry.html
new file mode 100644
index 0000000..3c3be3f
--- /dev/null
+++ b/templates/parts/taskEntry.html
@@ -0,0 +1,8 @@
+<option>-</option>
+{{ range $group, $tasks := index . 0}}
+<optgroup label="{{$group}}">
+ {{ range $task := $tasks }}
+ <option {{if eq $task.Id (index $ 1)}}selected{{end}} value="{{$task.Id}}">{{$task.Text}}</option>
+ {{ end }}
+</optgroup>
+{{ end }}
diff --git a/templates/parts/taskRows.html b/templates/parts/taskRows.html
index a2a6020..bef2366 100644
--- a/templates/parts/taskRows.html
+++ b/templates/parts/taskRows.html
@@ -1,11 +1,20 @@
<table>
<tbody hx-swap="outerHTML" hx-trigger="changedTasks from:body" hx-get="/task/list">
- {{ range $task := .Tasks }}
+ {{ range $group, $tasks := .GroupToTasks }}
<tr>
- <td>Trifork</td>
- <td />
- <td />
+ <td>{{ $group }}</td>
+ <td></td>
+ <td></td>
+ <td></td>
</tr>
+ {{ range $task := $tasks }}
+ <tr>
+ <td></td>
+ <td>{{ $task.Text }}</td>
+ <td>{{ if $task.Ident }}{{ $task.Ident }}{{end}}</td>
+ <td><button hx-trigger="click" hx-swap="outerHTML" hx-target="#taskForm" hx-get="/task/edit?id={{$task.Id}}" >e</button></td>
+ </tr>
+ {{ end }}
{{ end }}
</tbody>
</table>