blob: e940b8860b53e163c8401c21d6caa3c6bd4a4667 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package view
import (
"stevenlr.com/locker/model"
"fmt"
)
templ lock(t model.Lock) {
<p class="lock-row">
<a href={ templ.URL(fmt.Sprint("/lock/", t.Id)) }>{ t.Name }</a>
-
<a
href="javascript:void(0);"
hx-delete={ fmt.Sprint("/lock/", t.Id) }
hx-target="closest .lock-row"
hx-confirm={ fmt.Sprint("Are you sure you want to delete lock \"", t.Name , "\"?") }
>Delete</a>
</p>
}
templ LockCreateForm(lockName string, err string) {
<form
hx-put="/lock"
hx-target="closest .locks-list"
hx-target-error="this"
>
<p>
<input type="text" name="lockName" value={ lockName } placeholder="Name" />
<input type="number" name="days" placeholder="Days" />
<input type="number" name="hours" placeholder="Hours" />
<button type="submit">Create</button>
</p>
if err != "" {
<p class="error">{ err }</p>
}
</form>
}
templ LocksList(locks []model.Lock, isSignedIn bool) {
<div class="locks-list">
if isSignedIn {
<h1>Locks</h1>
for _, t := range locks {
@lock(t)
}
<h4>Create lock</h4>
@LockCreateForm("", "")
}
</div>
}
|