aboutsummaryrefslogtreecommitdiff
path: root/cmd/sklad/container.tmpl
blob: 7fa1654da8400aca16820cf2b38dd1312731bee8 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{{ define "Title" }}{{/*
*/}}{{ if .Container }}{{ .Container.Id }}{{ else }}Obaly{{ end }}{{ end }}
{{ define "Content" }}

{{ if .ErrorNoSuchSeries }}
<p>Chyba: Řada neexistuje.
{{ else if .ErrorContainerAlreadyExists }}
<p>Chyba: Obal s tímto ID už existuje.
{{ else if .ErrorNoSuchContainer }}
<p>Chyba: Obal neexistuje.
{{ else if .ErrorCannotChangeSeriesNotEmpty }}
<p>Chyba: Řadu u neprázdných obalů nelze měnit.
{{ else if .ErrorCannotChangeNumber }}
<p>Chyba: Číslo obalu v řadě nelze měnit.
{{ else if .ErrorWouldContainItself }}
<p>Chyba: Obal by obsahoval sám sebe.
{{ else if .ErrorContainerInUse }}
<p>Chyba: Obal se používá.
{{ else if .Error }}
<p>Chyba: {{ .Error }}
{{ end }}

{{ if .Container }}
<section>
	<header>
		<h2><a href="container?id={{ .Container.Id }}">{{ .Container.Id }}</a>
		{{- 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>
</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>
</section>

<h2>Obaly nejvyšší úrovně</h2>
{{ end }}

{{ 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>
			{{- 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ý.
{{ end }}

{{ end }}