aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/sklad/container.tmpl172
-rw-r--r--cmd/sklad/label.tmpl1
-rw-r--r--cmd/sklad/login.tmpl6
-rw-r--r--cmd/sklad/main.go5
-rw-r--r--cmd/sklad/search.tmpl30
-rw-r--r--cmd/sklad/series.tmpl55
6 files changed, 139 insertions, 130 deletions
diff --git a/cmd/sklad/container.tmpl b/cmd/sklad/container.tmpl
index 200bb19..f6d86ce 100644
--- a/cmd/sklad/container.tmpl
+++ b/cmd/sklad/container.tmpl
@@ -21,73 +21,73 @@
{{ end }}
{{ if .Container }}
-
<section>
-<header>
- <h2>{{ .Container.Id }}
-{{ range .Container.Path }}
- <small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
-{{ end }}
- </h2>
- <form method=post action="label?id={{ .Container.Id }}" target=_blank>
- <input type=submit value="Vytisknout štítek">
- </form>
- <form method=post action="container?id={{ .Container.Id }}&amp;remove">
- <input type=submit value="Odstranit">
+ <header>
+ <h2>{{ .Container.Id }}
+ {{- range .Container.Path }}
+ <small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
+ {{- end }}
+ </h2>
+ <form method=post action="label?id={{ .Container.Id }}" target=_blank>
+ <input type=submit value="Vytisknout štítek">
+ </form>
+ <form method=post action="container?id={{ .Container.Id }}&amp;remove">
+ <input type=submit value="Odstranit">
+ </form>
+ </header>
+ <form method=post action="container?id={{ .Container.Id }}">
+ <textarea name=description
+ rows="{{ max 5 (lines .Container.Description) }}"
+ placeholder="Popis obalu nebo jeho obsahu">
+ {{- .Container.Description -}}
+ </textarea>
+ <footer>
+ <div>
+ <label for=series>Řada:</label>
+ <select name=series id=series>
+ {{- range $prefix, $desc := .AllSeries }}
+ <option value="{{ $prefix }}"
+ {{ if eq $prefix $.Container.Series }}selected{{ end -}}
+ >{{ $prefix }} &mdash; {{ $desc }}</option>
+ {{- end }}
+ </select>
+ </div>
+ <div>
+ <label for=parent>Nadobal:</label>
+ <input type=text name=parent id=parent
+ value="{{ .Container.Parent }}">
+ </div>
+ <input type=submit value="Uložit">
+ </footer>
</form>
-</header>
-
-<form method=post action="container?id={{ .Container.Id }}">
-<textarea name=description rows="{{ max 5 (lines .Container.Description) }}"
- placeholder="Popis obalu nebo jeho obsahu">
-{{ .Container.Description }}</textarea>
-<footer>
- <div>
- <label for=series>Řada:</label>
- <select name=series id=series>
-{{ range $prefix, $desc := .AllSeries }}
- <option value="{{ $prefix }}"
- {{ if eq $prefix $.Container.Series }}selected{{ end }}
- >{{ $prefix }} &mdash; {{ $desc }}</option>
-{{ end }}
- </select>
- </div>
- <div>
- <label for=parent>Nadobal:</label>
- <input type=text name=parent id=parent value="{{ .Container.Parent }}">
- </div>
- <input type=submit value="Uložit">
-</footer>
-</form>
</section>
<h2>Podobaly</h3>
-
{{ else }}
<section>
-<header>
- <h2>Nový obal</h2>
-</header>
-<form method=post action="container">
-<textarea name=description rows=5
- placeholder="Popis obalu nebo jeho obsahu"></textarea>
-<footer>
- <div>
- <label for=series>Řada:</label>
- <select name=series id=series>
-{{ range $prefix, $desc := .AllSeries }}
- <option value="{{ $prefix }}"
- >{{ $prefix }} &mdash; {{ $desc }}</option>
-{{ end }}
- </select>
- </div>
- <div>
- <label for=parent>Nadobal:</label>
- <input type=text name=parent id=parent value="">
- </div>
- <input type=submit value="Uložit">
-</footer>
-</form>
+ <header>
+ <h2>Nový obal</h2>
+ </header>
+ <form method=post action="container">
+ <textarea name=description rows=5
+ placeholder="Popis obalu nebo jeho obsahu"></textarea>
+ <footer>
+ <div>
+ <label for=series>Řada:</label>
+ <select name=series id=series>
+ {{- range $prefix, $desc := .AllSeries }}
+ <option value="{{ $prefix }}"
+ >{{ $prefix }} &mdash; {{ $desc }}</option>
+ {{- end }}
+ </select>
+ </div>
+ <div>
+ <label for=parent>Nadobal:</label>
+ <input type=text name=parent id=parent value="">
+ </div>
+ <input type=submit value="Uložit">
+ </footer>
+ </form>
</section>
<h2>Obaly nejvyšší úrovně</h2>
@@ -95,28 +95,36 @@
{{ range .Children }}
<section>
-<header>
- <h3><a href="container?id={{ .Id }}">{{ .Id }}</a>
-{{ range .Path }}
- <small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
-{{ end }}
- </h3>
- <form method=post action="label?id={{ .Id }}" target=_blank>
- <input type=submit value="Vytisknout štítek">
- </form>
- <form method=post action="container?id={{ .Id }}&amp;remove">
- <input type=submit value="Odstranit">
- </form>
-</header>
-{{ if .Description }}
-<p>{{ .Description }}
-{{ end }}
-{{ if .Children }}
-<p>
-{{ range .Children }}
-<a href="container?id={{ .Id }}">{{ .Id }}</a>
-{{ end }}
-{{ end }}
+ <header>
+ <h3><a href="container?id={{ .Id }}">{{ .Id }}</a>
+ {{- range .Path }}
+ <small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
+ {{- end }}
+ </h3>
+ <form method=post action="label?id={{ .Id }}" target=_blank>
+ {{- if $.Container }}
+ <input type=hidden name=context value="{{ $.Container.Id }}">
+ {{- end }}
+ <input type=submit value="Vytisknout štítek">
+ </form>
+ <form method=post action="container?id={{ .Id }}&amp;remove">
+ {{- if $.Container }}
+ <input type=hidden name=context value="{{ $.Container.Id }}">
+ {{- end }}
+ <input type=submit value="Odstranit">
+ </form>
+ </header>
+
+ {{- if .Description }}
+ <p>{{ .Description }}
+ {{- end }}
+
+ {{- if .Children }}
+ <p>
+ {{- range .Children }}
+ <a href="container?id={{ .Id }}">{{ .Id }}</a>
+ {{- end }}
+ {{- end }}
</section>
{{ else }}
<p>Obal je prázdný.
diff --git a/cmd/sklad/label.tmpl b/cmd/sklad/label.tmpl
index 3880a03..08e971a 100644
--- a/cmd/sklad/label.tmpl
+++ b/cmd/sklad/label.tmpl
@@ -1,5 +1,6 @@
{{ define "Title" }}Tisk štítku{{ end }}
{{ define "Content" }}
+
<h2>Tisk štítku pro <a href="container?id={{ .Id }}">{{ .Id }}</a></h2>
{{ if .UnknownId }}
diff --git a/cmd/sklad/login.tmpl b/cmd/sklad/login.tmpl
index c34ab53..2c9ffc3 100644
--- a/cmd/sklad/login.tmpl
+++ b/cmd/sklad/login.tmpl
@@ -5,9 +5,9 @@
<h2>Přihlášení</h2>
<form method=post>
-<label for=password>Heslo:</label>
-<input type=password name=password id=password autofocus
-><input type=submit value="Přihlásit">
+ <label for=password>Heslo:</label>
+ <input type=password name=password id=password autofocus
+ ><input type=submit value="Přihlásit">
</form>
{{ if .IncorrectPassword }}
diff --git a/cmd/sklad/main.go b/cmd/sklad/main.go
index decd894..c08ce2b 100644
--- a/cmd/sklad/main.go
+++ b/cmd/sklad/main.go
@@ -103,8 +103,11 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
var err error
if r.Method == http.MethodPost {
err = handleContainerPost(r)
- // XXX: This is rather ugly. When removing, we want to keep
+ // FIXME: This is rather ugly. When removing, we want to keep
// the context id, in addition to the id being changed.
+ // TODO: If there were no errors, redirect the user to GET,
+ // which is related to the previous comment.
+ // TODO: If there were errors, use the last data as a prefill.
} else if r.Method != http.MethodGet {
w.WriteHeader(http.StatusMethodNotAllowed)
return
diff --git a/cmd/sklad/search.tmpl b/cmd/sklad/search.tmpl
index 9fef455..0c58bf9 100644
--- a/cmd/sklad/search.tmpl
+++ b/cmd/sklad/search.tmpl
@@ -1,16 +1,16 @@
{{ define "Title" }}&bdquo;{{ .Query }}&ldquo; &mdash; Vyhledávání{{ end }}
{{ define "Content" }}
-<h2>Vyhledávání: &bdquo;{{ .Query }}&ldquo;<h2>
+<h2>Vyhledávání: &bdquo;{{ .Query }}&ldquo;</h2>
<h3>Řady</h3>
{{ range .Series }}
<section>
-<header>
- <h3><a href="series?prefix={{ .Prefix }}">{{ .Prefix }}</a></h3>
- <p>{{ .Description }}
-</header>
+ <header>
+ <h3><a href="series?prefix={{ .Prefix }}">{{ .Prefix }}</a></h3>
+ <p>{{ .Description }}
+ </header>
</section>
{{ else }}
<p>Neodpovídají žádné řady.
@@ -20,16 +20,16 @@
{{ range .Containers }}
<section>
-<header>
- <h3><a href="container?id={{ .Id }}">{{ .Id }}</a>
-{{ range .Path }}
- <small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
-{{ end }}
- </h3>
-</header>
-{{ if .Description }}
-<p>{{ .Description }}
-{{ end }}
+ <header>
+ <h3><a href="container?id={{ .Id }}">{{ .Id }}</a>
+ {{- range .Path }}
+ <small>&laquo; <a href="container?id={{ . }}">{{ . }}</a></small>
+ {{- end }}
+ </h3>
+ </header>
+ {{- if .Description }}
+ <p>{{ .Description }}
+ {{- end }}
</section>
{{ else }}
<p>Neodpovídají žádné obaly.
diff --git a/cmd/sklad/series.tmpl b/cmd/sklad/series.tmpl
index fbc0e91..8bfaddc 100644
--- a/cmd/sklad/series.tmpl
+++ b/cmd/sklad/series.tmpl
@@ -22,45 +22,42 @@
<p>{{ .Description }}
{{ end }}
{{ else }}
-
<section>
-<form method=post action="series">
-<header>
- <h3>Nová řada</h3>
- <input type=text name=prefix placeholder="Prefix řady">
- <input type=text name=description placeholder="Popis řady"
- ><input type=submit value="Uložit">
+ <form method=post action="series">
+ <header>
+ <h3>Nová řada</h3>
+ <input type=text name=prefix placeholder="Prefix řady">
+ <input type=text name=description placeholder="Popis řady"
+ ><input type=submit value="Uložit">
+ </header>
</form>
-</header>
-</form>
</section>
{{ range .AllSeries }}
<section>
-<header>
- <h3><a href="series?prefix={{ .Prefix }}">{{ .Prefix }}</a></h3>
-{{ with $count := len .Containers }}
-{{ if eq $count 1 }}
- <p>{{ $count }} obal
-{{ else if and (ge $count 2) (le $count 4) }}
- <p>{{ $count }} obaly
-{{ else if gt $count 0 }}
- <p>{{ $count }} obalů
-{{ end }}
-{{ end }}
- <form method=post action="series?prefix={{ .Prefix }}">
- <input type=text name=description value="{{ .Description }}"
- ><input type=submit value="Uložit">
- </form>
- <form method=post action="series?prefix={{ .Prefix }}&amp;remove">
- <input type=submit value="Odstranit">
- </form>
-</header>
+ <header>
+ <h3><a href="series?prefix={{ .Prefix }}">{{ .Prefix }}</a></h3>
+ {{- with $count := len .Containers }}
+ {{- if eq $count 1 }}
+ <p>{{ $count }} obal
+ {{- else if and (ge $count 2) (le $count 4) }}
+ <p>{{ $count }} obaly
+ {{- else if gt $count 0 }}
+ <p>{{ $count }} obalů
+ {{- end }}
+ {{- end }}
+ <form method=post action="series?prefix={{ .Prefix }}">
+ <input type=text name=description value="{{ .Description }}"
+ ><input type=submit value="Uložit">
+ </form>
+ <form method=post action="series?prefix={{ .Prefix }}&amp;remove">
+ <input type=submit value="Odstranit">
+ </form>
+ </header>
</section>
{{ else }}
<p>Nejsou žádné řady.
{{ end }}
-
{{ end }}
{{ end }}