@viur/shop-components 0.0.1-dev.3 → 0.0.1-dev.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -37
- package/src/components/cart/CartLeaf.vue +195 -0
- package/src/components/cart/CartNode.vue +13 -0
- package/src/components/cart/CartView.vue +702 -0
- package/src/components/cart/ConfirmView.vue +314 -0
- package/src/components/order/category/CategoryList.vue +83 -0
- package/src/components/order/category/CategoryView.vue +143 -0
- package/src/components/order/information/UserInfoMulti.vue +429 -0
- package/src/components/order/information/UserInformation.vue +332 -0
- package/src/components/order/information/adress/ShippingAdress.vue +143 -0
- package/src/components/order/item/ItemCard.vue +168 -0
- package/src/components/order/item/ItemView.vue +233 -0
- package/src/components/order/process/ExampleUsage.vue +111 -0
- package/src/components/order/process/OrderComplete.vue +41 -0
- package/src/components/order/process/OrderTabHeader.vue +7 -0
- package/src/components/order/process/OrderView.vue +210 -0
- package/src/router/index.js +103 -0
- package/src/stores/cart.js +112 -0
- package/src/views/ViewMissing.vue +20 -0
- package/dist/shop-components.js +0 -36284
- package/dist/shop-components.umd.cjs +0 -6974
- package/dist/style.css +0 -1
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- <slot name="form" v-if="mode === 'form'">
|
|
3
|
+
<sl-spinner v-if="!state.isInit"></sl-spinner>
|
|
4
|
+
<form @submit.prevent="sendData" v-else>
|
|
5
|
+
<h2 class="viur-shop-form-input-headline headline">Nutzterdaten</h2>
|
|
6
|
+
<div class="viur-shop-form-wrap">
|
|
7
|
+
<sl-input
|
|
8
|
+
name="email"
|
|
9
|
+
v-model="state.formValues['email']"
|
|
10
|
+
placeholder="E-Mail"
|
|
11
|
+
class="viur-shop-form-grid-w-4"
|
|
12
|
+
>
|
|
13
|
+
<label slot="label">E-Mail*</label>
|
|
14
|
+
</sl-input>
|
|
15
|
+
<sl-input
|
|
16
|
+
name="name"
|
|
17
|
+
v-model="state.formValues['lastname']"
|
|
18
|
+
placeholder="Name"
|
|
19
|
+
class="viur-shop-form-grid-w-2"
|
|
20
|
+
>
|
|
21
|
+
<label slot="label">Name*</label>
|
|
22
|
+
</sl-input>
|
|
23
|
+
<sl-input
|
|
24
|
+
name="firstname"
|
|
25
|
+
v-model="state.formValues['firstname']"
|
|
26
|
+
placeholder="Vorname"
|
|
27
|
+
class="viur-shop-form-grid-w-2"
|
|
28
|
+
>
|
|
29
|
+
<label slot="label">Vorname*</label>
|
|
30
|
+
</sl-input>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="viur-shop-form-adress-wrapper">
|
|
33
|
+
<div class="viur-shop-form-adress-column">
|
|
34
|
+
<h2 class="viur-shop-form-input-headline headline">Lieferadresse</h2>
|
|
35
|
+
<component
|
|
36
|
+
:is="ShippingAdress"
|
|
37
|
+
v-bind="{
|
|
38
|
+
multiAdress: true,
|
|
39
|
+
items: cartStore.state.carts[cartStore.state.basket].items,
|
|
40
|
+
}"
|
|
41
|
+
v-for="a in state.shippingAdressAmount"
|
|
42
|
+
:key="a"
|
|
43
|
+
@adressInput="log"
|
|
44
|
+
@itemSelection="log"
|
|
45
|
+
></component>
|
|
46
|
+
|
|
47
|
+
<div class="viur-shop-form-btn-wrap">
|
|
48
|
+
|
|
49
|
+
<sl-button
|
|
50
|
+
size="medium"
|
|
51
|
+
@click="decreaseAdress"
|
|
52
|
+
title="Lieferadresse entfernen"
|
|
53
|
+
>
|
|
54
|
+
<sl-icon name="x-lg"
|
|
55
|
+
slot="prefix"></sl-icon>
|
|
56
|
+
</sl-button>
|
|
57
|
+
<sl-button
|
|
58
|
+
size="medium"
|
|
59
|
+
variant="primary"
|
|
60
|
+
@click="increaseAdress"
|
|
61
|
+
>
|
|
62
|
+
<sl-icon name="plus-lg"
|
|
63
|
+
slot="prefix"></sl-icon>
|
|
64
|
+
Lieferadresse hinzufügen
|
|
65
|
+
</sl-button>
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<sl-alert
|
|
70
|
+
variant="warning"
|
|
71
|
+
duration="2000"
|
|
72
|
+
ref="shippingWarning"
|
|
73
|
+
closable
|
|
74
|
+
>
|
|
75
|
+
<sl-icon slot="icon" name="exclamation-triangle"></sl-icon>
|
|
76
|
+
<strong>{{ state.amountAlert.title }} </strong><br />
|
|
77
|
+
{{ state.amountAlert.msg }}
|
|
78
|
+
</sl-alert>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
<sl-checkbox @sl-change="onCustomAdressChange" checked>
|
|
83
|
+
Rechnungsadresse wie Lieferadresse
|
|
84
|
+
</sl-checkbox>
|
|
85
|
+
|
|
86
|
+
<div class="viur-shop-form-adress-column" v-show="state.isCustomAdress">
|
|
87
|
+
<h2 class="viur-shop-form-headline headline">Rechnungsadresse</h2>
|
|
88
|
+
<div class="viur-shop-form-wrap">
|
|
89
|
+
<sl-input
|
|
90
|
+
name="street"
|
|
91
|
+
v-model="state.formValues['billing.street']"
|
|
92
|
+
placeholder="Straße"
|
|
93
|
+
class="viur-shop-form-grid-w-3"
|
|
94
|
+
>
|
|
95
|
+
<label slot="label">Strasse *</label>
|
|
96
|
+
</sl-input>
|
|
97
|
+
<sl-input
|
|
98
|
+
name="street"
|
|
99
|
+
v-model="state.formValues['billing.streetnumber']"
|
|
100
|
+
placeholder="Hausnummer"
|
|
101
|
+
type="number"
|
|
102
|
+
>
|
|
103
|
+
<label slot="label">Hausnummer *</label>
|
|
104
|
+
</sl-input>
|
|
105
|
+
<sl-input
|
|
106
|
+
name="street"
|
|
107
|
+
v-model="state.formValues['billing.areacode']"
|
|
108
|
+
placeholder="Postleitzahl"
|
|
109
|
+
type="number"
|
|
110
|
+
class="viur-shop-form-grid-w-2"
|
|
111
|
+
>
|
|
112
|
+
<label slot="label">Postleitzahl *</label>
|
|
113
|
+
</sl-input>
|
|
114
|
+
<sl-input
|
|
115
|
+
name="city"
|
|
116
|
+
v-model="state.formValues['billing.city']"
|
|
117
|
+
placeholder="Stadt"
|
|
118
|
+
class="viur-shop-form-grid-w-2"
|
|
119
|
+
>
|
|
120
|
+
<label slot="label">Stadt*</label>
|
|
121
|
+
</sl-input>
|
|
122
|
+
<sl-input
|
|
123
|
+
name="province"
|
|
124
|
+
v-model="state.formValues['billing.province']"
|
|
125
|
+
placeholder="Bundesland"
|
|
126
|
+
class="viur-shop-form-grid-w-2"
|
|
127
|
+
>
|
|
128
|
+
<label slot="label">Bundesland</label>
|
|
129
|
+
</sl-input>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
</form>
|
|
134
|
+
</slot> -->
|
|
135
|
+
|
|
136
|
+
<div>
|
|
137
|
+
<h2 class="viur-shop-form-headline headline">Nutzterdaten</h2>
|
|
138
|
+
<template v-for="item in state.addSkel" :key="item[0]">
|
|
139
|
+
<bone
|
|
140
|
+
:is="getBoneWidget(item[1].type)"
|
|
141
|
+
v-if="item[1].visible && item[1].params.group === 'Customer Info'"
|
|
142
|
+
:name="item[0]"
|
|
143
|
+
:structure="structToDict(state.addSkel)"
|
|
144
|
+
:errors="state.errors[item[0]] ? state.errors[item[0]] : []"
|
|
145
|
+
:skel="state.formValues"
|
|
146
|
+
@change="changeEvent(item[0], $event)"
|
|
147
|
+
class="viur-shop-form-grid-w-2"
|
|
148
|
+
>
|
|
149
|
+
</bone>
|
|
150
|
+
</template>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<h2 class="viur-shop-form-headline headline">Lieferadresse</h2>
|
|
154
|
+
<div v-for="a in state.shippingAdressAmount" :key="a">
|
|
155
|
+
<sl-select
|
|
156
|
+
clearable
|
|
157
|
+
ref="itemSelection"
|
|
158
|
+
@sl-change="onItemSelect($event, a)"
|
|
159
|
+
@sl-clear="onItemReset($event, a)"
|
|
160
|
+
:label="state.selectedItem[a] ? cartStore.state.carts[state.selectedItem[a]].info.name : 'Warenkorb für Adresse wählen.'"
|
|
161
|
+
class="grid-w-4"
|
|
162
|
+
>
|
|
163
|
+
<sl-option v-for="(v, k) in cartStore.state.carts" :value="k">
|
|
164
|
+
{{ v.info.name }}</sl-option
|
|
165
|
+
>
|
|
166
|
+
</sl-select>
|
|
167
|
+
<template v-for="item in state.addSkel" :key="item[0]">
|
|
168
|
+
<bone
|
|
169
|
+
:is="getBoneWidget(item[1].type)"
|
|
170
|
+
v-if="item[1].visible && item[1].params.group === 'Customer Address'"
|
|
171
|
+
:name="item[0]"
|
|
172
|
+
:structure="structToDict(state.addSkel)"
|
|
173
|
+
:errors="state.errors[item[0]] ? state.errors[item[0]] : []"
|
|
174
|
+
:skel="state.formValues"
|
|
175
|
+
@change="changeEvent(item[0], $event)"
|
|
176
|
+
>
|
|
177
|
+
</bone>
|
|
178
|
+
</template>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div v-if="state.isCustomAdress">
|
|
182
|
+
<h2 class="viur-shop-form-headline headline">Rechnungsadresse</h2>
|
|
183
|
+
<template v-for="item in state.addSkel" :key="item[0]">
|
|
184
|
+
<bone
|
|
185
|
+
:is="getBoneWidget(item[1].type)"
|
|
186
|
+
v-if="item[1].visible && item[1].params.group === 'Customer Address'"
|
|
187
|
+
:name="item[0]"
|
|
188
|
+
:structure="structToDict(state.addSkel)"
|
|
189
|
+
:errors="state.errors[item[0]] ? state.errors[item[0]] : []"
|
|
190
|
+
:skel="state.formValues"
|
|
191
|
+
@change="changeEvent(item[0], $event)"
|
|
192
|
+
>
|
|
193
|
+
</bone>
|
|
194
|
+
</template>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div class="viur-shop-form-btn-wrap">
|
|
198
|
+
<sl-button
|
|
199
|
+
size="medium"
|
|
200
|
+
@click="decreaseAdress"
|
|
201
|
+
title="Lieferadresse entfernen"
|
|
202
|
+
>
|
|
203
|
+
<sl-icon name="x-lg" slot="prefix"></sl-icon>
|
|
204
|
+
</sl-button>
|
|
205
|
+
<sl-button size="medium" variant="primary" @click="increaseAdress">
|
|
206
|
+
<sl-icon name="plus-lg" slot="prefix"></sl-icon>
|
|
207
|
+
Lieferadresse hinzufügen
|
|
208
|
+
</sl-button>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<sl-alert variant="warning" duration="2000" ref="shippingWarning" closable>
|
|
212
|
+
<sl-icon slot="icon" name="exclamation-triangle"></sl-icon>
|
|
213
|
+
<strong>{{ state.amountAlert.title }} </strong><br />
|
|
214
|
+
{{ state.amountAlert.msg }}
|
|
215
|
+
</sl-alert>
|
|
216
|
+
|
|
217
|
+
<sl-checkbox @sl-change="onCustomAdressChange" checked>
|
|
218
|
+
Rechnungsadresse wie Lieferadresse
|
|
219
|
+
</sl-checkbox>
|
|
220
|
+
</template>
|
|
221
|
+
|
|
222
|
+
<script setup>
|
|
223
|
+
|
|
224
|
+
import { reactive, computed, watch, ref, onBeforeMount } from "vue";
|
|
225
|
+
// import ShippingAdress from "./adress/ShippingAdress.vue";
|
|
226
|
+
import { useCartStore } from "../../../stores/cart";
|
|
227
|
+
import Wrapper_nested from "@viur/vue-utils/bones/edit/wrapper_nested.vue";
|
|
228
|
+
import bone from "@viur/vue-utils/bones/edit/bone.vue";
|
|
229
|
+
import { getBoneWidget } from "@viur/vue-utils/bones/edit/index";
|
|
230
|
+
|
|
231
|
+
const props = defineProps({
|
|
232
|
+
mode: { type: String, default: "form" },
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const cartStore = useCartStore();
|
|
236
|
+
|
|
237
|
+
const state = reactive({
|
|
238
|
+
formValues: {},
|
|
239
|
+
requiredFieldsFilled: computed(() => {
|
|
240
|
+
// TODO: automatisierte logik anhand der required felder aus struktur der bones
|
|
241
|
+
if (state.isCustomAdress) {
|
|
242
|
+
return (
|
|
243
|
+
Object.keys(state.formValues).includes("city") &&
|
|
244
|
+
Object.keys(state.formValues).includes("street") &&
|
|
245
|
+
Object.keys(state.formValues).includes("billing.city") &&
|
|
246
|
+
Object.keys(state.formValues).includes("billing.street") &&
|
|
247
|
+
Object.keys(state.formValues).includes("email") &&
|
|
248
|
+
Object.keys(state.formValues).includes("firstname") &&
|
|
249
|
+
Object.keys(state.formValues).includes("lastname")
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
if (!state.isCustomAdress) {
|
|
253
|
+
return (
|
|
254
|
+
Object.keys(state.formValues).includes("city") &&
|
|
255
|
+
Object.keys(state.formValues).includes("street") &&
|
|
256
|
+
Object.keys(state.formValues).includes("email") &&
|
|
257
|
+
Object.keys(state.formValues).includes("firstname") &&
|
|
258
|
+
Object.keys(state.formValues).includes("lastname")
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}),
|
|
262
|
+
isCustomAdress: false,
|
|
263
|
+
shippingAdressAmount: 1,
|
|
264
|
+
maxShippingAdress: computed(
|
|
265
|
+
() => Object.keys(cartStore.state.carts).length + 2,
|
|
266
|
+
),
|
|
267
|
+
amountAlert: { title: "", msg: "" },
|
|
268
|
+
items: null,
|
|
269
|
+
addSkel: null,
|
|
270
|
+
errors: {},
|
|
271
|
+
selectedItem: {},
|
|
272
|
+
isInit: computed(() => {
|
|
273
|
+
if (cartStore.state.carts[cartStore.state.basket]) {
|
|
274
|
+
return true;
|
|
275
|
+
} else {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
}),
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
const itemSelection = ref(null);
|
|
282
|
+
const shippingWarning = ref(null);
|
|
283
|
+
|
|
284
|
+
// function updateFormValues(e){
|
|
285
|
+
// state.formValues[e.target.name] = e.target.value
|
|
286
|
+
// }
|
|
287
|
+
|
|
288
|
+
function sendData(e) {
|
|
289
|
+
console.log("sende daten...", state.formValues);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function onCustomAdressChange(e) {
|
|
293
|
+
if (e.target.checked) state.isCustomAdress = false;
|
|
294
|
+
if (!e.target.checked) state.isCustomAdress = true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function increaseAdress() {
|
|
298
|
+
if (state.shippingAdressAmount === state.maxShippingAdress) {
|
|
299
|
+
state.amountAlert.title = "Zu viele Lieferadressen";
|
|
300
|
+
state.amountAlert.msg = `Sie können nur maximal: "${state.maxShippingAdress}" Lieferadressen verwenden.`;
|
|
301
|
+
shippingWarning.value.show();
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
state.shippingAdressAmount += 1;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function changeEvent(boneName, ev) {
|
|
308
|
+
for (const [key, value] of Object.entries(ev.value[0])) {
|
|
309
|
+
state.formValues[key] = value;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function decreaseAdress() {
|
|
314
|
+
if (state.shippingAdressAmount === 1) {
|
|
315
|
+
state.amountAlert.title = "Zu wenig Lieferadressen";
|
|
316
|
+
state.amountAlert.msg =
|
|
317
|
+
"Mindestens eine Lieferadresse muss angegeben werden.";
|
|
318
|
+
shippingWarning.value.show();
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
state.shippingAdressAmount -= 1;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function log(e) {
|
|
325
|
+
console.log("emit hier", e);
|
|
326
|
+
Object.assign(state.formValues, e);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function onItemSelect(e, a) {
|
|
330
|
+
console.log(e.target.value);
|
|
331
|
+
if (!e.target.value.length) {
|
|
332
|
+
onItemReset();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
state.selectedItem[a] = e.target.value;
|
|
336
|
+
state.isItemSelected = true;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function onItemReset(e, a) {
|
|
340
|
+
console.log("clearing...");
|
|
341
|
+
delete state.selectedItem[a]
|
|
342
|
+
state.isItemSelected = false;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function getLabel(cart) {
|
|
346
|
+
console.log("hier", cart)
|
|
347
|
+
if (cart) {
|
|
348
|
+
return "Lieferadresse für: " + cartStore.state.carts[cart].info.name;
|
|
349
|
+
}
|
|
350
|
+
return "Warenkorb für Lieferadresse wählen.";
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function structToDict(structure) {
|
|
354
|
+
let output = {};
|
|
355
|
+
|
|
356
|
+
structure.forEach((bone) => {
|
|
357
|
+
let boneName = bone[0];
|
|
358
|
+
let boneValues = bone[1];
|
|
359
|
+
|
|
360
|
+
output[boneName] = boneValues;
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
return output;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
watch(state.formValues, (newValues) => {
|
|
367
|
+
Object.entries(newValues).forEach(([k, v]) => {
|
|
368
|
+
if (v === "") {
|
|
369
|
+
delete state.formValues[k];
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
onBeforeMount(async () => {
|
|
375
|
+
await cartStore.getAdressStructure();
|
|
376
|
+
state.addSkel = cartStore.state.structure.address;
|
|
377
|
+
});
|
|
378
|
+
</script>
|
|
379
|
+
|
|
380
|
+
<style scoped>
|
|
381
|
+
.viur-shop-form-footer {
|
|
382
|
+
display: flex;
|
|
383
|
+
justify-content: space-between;
|
|
384
|
+
margin-top: var(--sl-spacing-large);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.viur-shop-form-adress-wrapper {
|
|
388
|
+
display: flex;
|
|
389
|
+
flex-direction: column;
|
|
390
|
+
gap: 1rem;
|
|
391
|
+
width: 100%;
|
|
392
|
+
justify-content: space-around;
|
|
393
|
+
align-items: flex-start;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.viur-shop-form-adress-column {
|
|
397
|
+
align-self: flex-start;
|
|
398
|
+
flex-grow: 1;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.viur-shop-form-wrap {
|
|
402
|
+
display: grid;
|
|
403
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
404
|
+
gap: 0 var(--sl-spacing-medium);
|
|
405
|
+
margin: var(--sl-spacing-large) 0;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.viur-shop-form-grid-w-2 {
|
|
409
|
+
grid-column: span 2;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
.viur-shop-form-grid-w-3 {
|
|
413
|
+
grid-column: span 3;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.viur-shop-form-grid-w-4 {
|
|
417
|
+
grid-column: span 4;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.viur-shop-form-btn-wrap {
|
|
421
|
+
display: flex;
|
|
422
|
+
flex-direction: row;
|
|
423
|
+
flex-wrap: nowrap;
|
|
424
|
+
justify-content: space-between;
|
|
425
|
+
width: 100%;
|
|
426
|
+
|
|
427
|
+
margin-top: var(--sl-spacing-x-large);
|
|
428
|
+
}
|
|
429
|
+
</style>
|