Files
farmcal/templates/fields.html

104 lines
4.3 KiB
HTML

<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FarmCal - Felder</title>
<link rel="icon" type="image/svg+xml" href="/static/farmcal-icon.svg">
<link rel="stylesheet" href="/static/styles.css">
</head>
<body>
<header class="top"><h1><img src="/static/farmcal-icon.svg" alt="" class="brand-icon">FarmCal</h1><p>Felder und Feldgruppen</p></header>
<nav class="tabs">
<a href="/" class="{{if eq .ActivePath "/"}}active{{end}}">Dashboard</a>
<a href="/planning" class="{{if eq .ActivePath "/planning"}}active{{end}}">Anbau planen</a>
<a href="/crops" class="{{if eq .ActivePath "/crops"}}active{{end}}">Feldfrüchte</a>
<a href="/fields" class="{{if eq .ActivePath "/fields"}}active{{end}}">Felder & Gruppen</a>
<a href="/general" class="{{if eq .ActivePath "/general"}}active{{end}}">Allgemein</a>
</nav>
<main class="layout">
<section class="card">
<h2>Feld anlegen</h2>
<form method="post" action="/fields/create" class="grid">
<label>Feldnummer<input type="number" name="number" min="1" required></label>
<label>Name (optional)<input type="text" name="name" maxlength="120"></label>
<label class="check"><input type="checkbox" name="owned"> Im Besitz</label>
<button type="submit">Anlegen</button>
</form>
</section>
<section class="card full-width">
<h2>Felder verwalten</h2>
<div class="table-wrap">
<table>
<thead><tr><th>Nummer</th><th>Name</th><th>Besitz</th><th>Gruppe</th><th>Aktionen</th></tr></thead>
<tbody>
{{if .Fields}}
{{range .Fields}}
<tr>
<form method="post" action="/fields/update">
<td>Feld {{.Number}}<input type="hidden" name="id" value="{{.ID}}"></td>
<td><input type="text" name="name" value="{{.Name}}" maxlength="120"></td>
<td><label class="check"><input type="checkbox" name="owned" {{if .Owned}}checked{{end}}> Im Besitz</label></td>
<td>{{if .GroupName}}{{.GroupName}}{{else}}-{{end}}</td>
<td class="actions">
<button type="submit" class="btn-small">Speichern</button>
<button type="submit" formaction="/fields/delete" formnovalidate class="btn-small danger" onclick="return confirm('Feld wirklich löschen?')">Löschen</button>
</td>
</form>
</tr>
{{end}}
{{else}}
<tr><td colspan="5">Keine Felder vorhanden.</td></tr>
{{end}}
</tbody>
</table>
</div>
</section>
<section class="card full-width">
<h2>Feldgruppen</h2>
<form method="post" action="/field-groups/create" class="grid">
<label class="full">Name (optional)<input type="text" name="name" maxlength="120" placeholder="z.B. Feld 1+2"></label>
<label class="full">Felder (1 bis X)
<select name="field_ids" multiple size="8">
{{range .Fields}}
<option value="{{.ID}}">Feld {{.Number}}{{if .Name}} ({{.Name}}){{end}}</option>
{{end}}
</select>
</label>
<button type="submit">Gruppe speichern</button>
</form>
<p class="hint">Mehrfachauswahl mit Strg/Cmd.</p>
<div class="table-wrap mt">
<table>
<thead><tr><th>Name</th><th>Felder</th><th>Aktion</th></tr></thead>
<tbody>
{{if .Groups}}
{{range .Groups}}
<tr>
<td>{{.Name}}</td>
<td>{{.Numbers}}</td>
<td>
<form method="post" action="/field-groups/delete">
<input type="hidden" name="group_key" value="{{.Key}}">
<button type="submit" class="btn-small danger" onclick="return confirm('Gruppe auflösen?')">Auflösen</button>
</form>
</td>
</tr>
{{end}}
{{else}}
<tr><td colspan="3">Keine Gruppen vorhanden.</td></tr>
{{end}}
</tbody>
</table>
</div>
</section>
</main>
{{if .Error}}<div class="toast error">{{.Error}}</div>{{end}}
{{if .Info}}<div class="toast info">{{.Info}}</div>{{end}}
</body>
</html>