| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8" /> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 6 | <meta name="theme-color" content="#121113" /> |
| 7 | <link rel="stylesheet" href="/assets/darkmatter.css" /> |
| 8 | <link rel="stylesheet" href="/static/styles.css" /> |
| 9 | <title>Habbits | Settings</title> |
| 10 | </head> |
| 11 | <body> |
| 12 | <div class="header"> |
| 13 | <a href="/" class="logo">HABBITS</a> |
| 14 | <nav class="links"> |
| 15 | <a href="/">dashboard</a> |
| 16 | <a href="/new">new habit</a> |
| 17 | <a href="/logout">logout</a> |
| 18 | </nav> |
| 19 | </div> |
| 20 | |
| 21 | {{if .Success}}<p class="success">{{.Success}}</p>{{end}} |
| 22 | {{if .Error}}<p class="error">{{.Error}}</p>{{end}} |
| 23 | |
| 24 | {{$types := .ValueTypes}} |
| 25 | |
| 26 | <section class="section"> |
| 27 | <div class="admin-toolbar"> |
| 28 | <h2>Habits ({{len .Habits}})</h2> |
| 29 | <div class="admin-list-actions"> |
| 30 | {{if .Habits}}<a href="/export.csv">export all (csv)</a>{{end}} |
| 31 | <a href="/new">new habit</a> |
| 32 | </div> |
| 33 | </div> |
| 34 | |
| 35 | {{if not .Habits}} |
| 36 | <p class="empty">No habits yet. <a href="/new">Create one</a>.</p> |
| 37 | {{else}} |
| 38 | {{range .Habits}} |
| 39 | <div class="settings-habit"> |
| 40 | <form class="form" method="POST" action="/habits/{{.ShortID}}"> |
| 41 | <div class="form-row"> |
| 42 | <div class="form-field"> |
| 43 | <label>Name</label> |
| 44 | <input type="text" name="name" value="{{.Name}}" required /> |
| 45 | </div> |
| 46 | <div class="form-field"> |
| 47 | <label>Value type</label> |
| 48 | <select name="value_type" required> |
| 49 | {{$vt := .ValueType}} |
| 50 | {{range $types}}<option value="{{.}}"{{if eq . $vt}} selected{{end}}>{{.}}</option>{{end}} |
| 51 | </select> |
| 52 | </div> |
| 53 | <div class="form-field"> |
| 54 | <label>Unit</label> |
| 55 | <input type="text" name="unit" value="{{.Unit}}" placeholder="optional" /> |
| 56 | </div> |
| 57 | </div> |
| 58 | <div class="form-field"> |
| 59 | <label>Description</label> |
| 60 | <input type="text" name="description" value="{{.Description}}" placeholder="optional" /> |
| 61 | </div> |
| 62 | <div class="form-actions"> |
| 63 | <button type="submit">Save</button> |
| 64 | <a href="/export.csv?habit={{.ShortID}}">export (csv)</a> |
| 65 | <span class="admin-list-date">{{.RecordCount}} record{{if ne .RecordCount 1}}s{{end}}</span> |
| 66 | </div> |
| 67 | </form> |
| 68 | <form method="POST" action="/habits/{{.ShortID}}/delete" class="inline-form" onsubmit="return confirm('Delete this habit and all its records?')"> |
| 69 | <input type="hidden" name="return_to" value="/settings" /> |
| 70 | <button type="submit" class="link-button danger">delete habit</button> |
| 71 | </form> |
| 72 | </div> |
| 73 | {{end}} |
| 74 | {{end}} |
| 75 | </section> |
| 76 | </body> |
| 77 | </html> |