forked from drgirasol/rezepte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_alt.html
267 lines (254 loc) · 11.7 KB
/
index_alt.html
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rezepteingabe</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/pouchdb.min.js"></script>
<script src="js/pouchdb.find.js"></script>
<script type="module" src="js/app.js"></script>
<style>
.thumbnail {
max-width: 150px; /* Die maximale Breite des Thumbnails */
max-height: 150px; /* Die maximale Höhe des Thumbnails */
width: auto; /* Die Breite wird automatisch angepasst */
height: auto; /* Die Höhe wird automatisch angepasst */
}
</style>
</head>
<body>
<template id="foto-form-template">
<div class="flex items-stretch p-2" @mounted="init()">
<h4>Foto hochladen</h4>
<div class="p-2">
<form method="post" enctype="multipart/form-data">
<div class="pb-2">
<label for="fotosToProcess">Fotos auswählen</label>
<input class="form-control" type="file" id="fotosToProcess"
accept="image/png, image/jpeg">
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary" type="button" @click="processFotos">Hochladen</button>
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary" @click="fotoAbbrechen">Abbrechen</button>
</div>
</form>
</div>
</div>
</template>
<template id="foto-list-template">
<div class="flex items-stretch p-2" @mounted="init()">
<ol>
<li v-for="img of bilder" :idx="img.name">
<img class="thumbnail" :src="img.url">
</li>
</ol>
<hr>
</div>
</template>
<template id="schritt-produkt-form-template">
<!--Step Indicators-->
<div class="flex items-stretch p-2" @mounted="init()">
<h4>Produktangaben anpassen</h4>
<div class="p-2">
<div class="pb-2">
<label for="prodName">Name</label>
<input readonly placeholder="Name" class="form-control" type="text" v-model="schrittProdukt.produktId"
required>
</div>
<div class="pb-2">
<label for="prodName">Preis</label>
<input v-model="schrittProdukt.preis" class="form-control" type="number" placeholder="Preis in Cent">
</div>
<div class="pb-2">
<label for="prodName">Gewicht</label>
<input v-model="schrittProdukt.gewicht" class="form-control" type="number"
placeholder="Gewicht in Gramm">
</div>
<div class="row">
<button class="col btn btn-primary" type="submit" @click="insertSchrittProdukt">Übernehmen</button>
<button class="col btn btn-primary" @click="schrittProduktAbbrechen">Abbrechen</button>
</div>
</div>
</div>
</template>
<template id="produkt-form-template">
<!--Step Indicators-->
<div class="flex items-stretch p-2" @mounted="init()">
<h4>Produkt hinzufügen</h4>
<div class="p-2">
<div class="pb-2">
<label for="prodName">Name</label>
<input placeholder="Name" class="form-control" type="text" v-model="name" id="prodName" required>
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary" type="submit" @click="insertProdukt">Hinzufügen</button>
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary" @click="produktAbbrechen">Abbrechen</button>
</div>
</div>
<!-- <div id="produktList" class="pt-4">
<ol>
<li v-for="produkt of produkte" :idx="produkt._id">
{{ produkt._id }} , {{ produkt.gewicht}} Gramm, {{produkt.preis}} Cent
<a class="btn btn-primary" @click="edit(produkt._id)"><i class="bi-pencil"></i></a>
</li>
</ol>
</div>-->
</div>
</template>
<template id="material-form-template">
<!--Step Indicators-->
<div class="flex items-stretch p-2" @mounted="init()">
<h4>Material hinzufügen</h4>
<div class="p-2">
<div class="pb-2">
<label for="matName">Name</label>
<input placeholder="Name" class="form-control" type="text" v-model="name" id="matName" required>
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary" type="submit" @click="insertMaterial">Hinzufügen</button>
</div>
<div class="d-grid gap-2">
<button class="btn btn-primary" @click="materialAbbrechen">Abbrechen</button>
</div>
</div>
<!-- <div id="materialList" class="pt-4">
<ol>
<li v-for="material of materialien" :idx="material._id">
{{ material._id }}
<a class="btn btn-primary" @click="edit(material._id)"><i class="bi-pencil"></i></a>
</li>
</ol>
</div>-->
</div>
</template>
<template id="rezept-list-template">
<!--Step Indicators-->
<div class="flex items-stretch p-2" @mounted="init()">
<h4>Rezepte <button type="button" @click="close()"><i class="bi-x-lg"></i></button></h4>
<ol>
<li v-for="r of rezepte" :idx="r._id">
{{ r.name }}
<a href="#" @click="edit(r._id)"><i class="bi-pencil"></i></a>
</li>
</ol>
<hr>
</div>
</template>
<div v-scope @mounted="onMounted()" id="Rezeptformular" class="p-2">
<div
v-if="showRezepteList"
ref="rezeptList"
v-scope="rezeptListKomponente({ rezepte: rezepte })"
@close="showRezepteList=false"
@edit="loadRezept"></div>
<div
v-if="rezepte.length"
class="p-2"
>
Gespeicherte Rezepte: <button type="button" class="btn btn-outline-success btn-sm" @click="showRezepteList=true"><i class="bi-list"></i>{{ rezepte.length }}</button>
</div>
<div v-if="!addProdukt && !addMaterial && !addSchrittProdukt">
<!--Zukünftige Rezept Formular Komponente / Template-->
<div class="input-group">
<span class="input-group-text">Rezeptname</span>
<input v-model="fRezeptName" class="form-control" placeholder="Name" @change="checkIfRezeptExists()">
</div>
<div v-if="rezeptExists">
Rezept "{{ fRezeptName }}" existiert
<button type="button" class="btn btn-outline-success btn-sm" @click="loadRezept()">Laden</button>
</div>
<div v-if="curRezept.anleitung && curRezept.anleitung.schritte.length > 0" class="p-2">
<p class="h4 pt-3">Anleitung</p>
<div v-for="aSchritt of curRezept.anleitung.schritte">
<div class="p-2" id="stepForm">
<div class="row gy-2">
<div class="input-group">
<span class="input-group-text">Arbeitsschritt {{ aSchritt.nr }}</span>
<input v-model="aSchritt.text" class="form-control"
@input="setSchrittChanged(aSchritt.nr)">
</div>
<div class="input-group">
<span class="input-group-text">Dauer</span>
<input v-model="aSchritt.zeit.dauer" class="form-control" type="number" id="dauer"
name="dauer" placeholder="Dauer in Minuten">
</div>
<div class="input-group">
<span class="input-group-text">Typ</span>
<select :value="aSchritt.zeit.typ" class="form-select" name="Typ" id="Gartyp">
<option value="kochen">kochen</option>
<option value="backen">backen</option>
</select>
</div>
<div>
Materialien: {{ aSchritt.materialien.map(m => m._id).join(", ") }}
</div>
<div class="input-group">
<select @change="onMaterialChange(event, aSchritt.nr)" v-model="fMaterial"
class="form-select">
<option value="" disabled selected hidden>Material auswählen</option>
<option v-for="m of materialien" :idx="m._id">
{{ m._id }}
</option>
<option label="Neues Material hinzufügen" :value="0"/>
</select>
</div>
<div>
Produkte: {{ aSchritt.produkte.map(p => p.produktId + ' (' + p.gewicht + 'g)').join(", ") }}
</div>
<div class="input-group">
<select @change="onProduktChange(event, aSchritt.nr)" v-model="fProdukt"
class="form-select">
<option value="" label="Produkt auswählen" selected hidden></option>
<option v-for="p of getProduktSelection(aSchritt.nr)" :idx="p._id">
{{ p._id }}
</option>
<option label="Neues Produkt hinzufügen" value="0"></option>
</select>
</div>
</div>
</div>
<hr>
</div>
<button type="button" class="btn btn-outline-success btn-sm" @click="addStep()">Schritt
hinzufügen
</button>
<div v-if="curRezept._id">
<div ref="fotoListe" v-scope="fotoListKomponente({ rezept: curRezept, self: this })"></div>
<div ref="fotoUploadForm" v-scope="fotoFormKomponente({ pdb: PouchDB, self: this })"
@save="saveAttachments" @finished="attachmentsHinzugefuegt" @canceled=""></div>
</div>
<button class="btn btn-primary" type="submit" :disabled="!fRezeptName || rezeptExists"
@click="saveRezept()">Speichern
</button>
</div>
</div>
<div v-if="addProdukt">
<div ref="produktform"
v-scope="produktFormKomponente({ name: '', pdb: PouchDB, self: this })"
@finished="produktHinzugefuegt"
@canceled="addProdukt=false"></div>
</div>
<div v-if="addSchrittProdukt">
<div ref="schrittProduktform"
v-scope="schrittProduktFormKomponente({ produkt: curProdukt, schritt: curSchritt, rezept: curRezept, pdb: PouchDB, self: this })"
@finished="schrittProduktHinzugefuegt"
@canceled="addSchrittProdukt=false">
</div>
</div>
<div v-if="addMaterial">
<div ref="materialform"
v-scope="materialFormKomponente({ name: '', pdb: PouchDB, self: this })"
@finished="materialHinzugefuegt"
@canceled="addMaterial=false"></div>
</div>
<div id="dbCount"></div>
</div>
</body>
</html>