@viur/shop-components 0.0.1-dev.3 → 0.0.1-dev.4

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.
@@ -0,0 +1,691 @@
1
+ <template>
2
+ <Loader v-if="!state.cartIsInit"></Loader>
3
+ <template v-else>
4
+ <div class="bind viur-shop-cart-wrap">
5
+
6
+ <sl-dialog ref="confirm" @sl-hide="onDialogHide">
7
+ <p>Möchten Sie den Artikel wirklich aus dem Warenkorb entfernen?</p>
8
+ <div class="footer-wrap" slot="footer">
9
+ <sl-button variant="danger" @click="confirm.hide()" size="medium">
10
+ Abbrechen
11
+ </sl-button>
12
+ <sl-button variant="success" @click="onConfirm" size="medium">
13
+ Aus Warenkorb entfernen
14
+ </sl-button>
15
+ </div>
16
+ </sl-dialog>
17
+
18
+ <div class="viur-shop-cart-list">
19
+ <div class="viur-shop-cart-controlbar" v-if="mode !== 'basket'">
20
+ <div class="viur-shop-cart-button-list left">
21
+ <sl-input
22
+ ref="cartNameField"
23
+ name="cart-name"
24
+ placeholder="Warenkorbname"
25
+ v-model="cartStore.state.carts[cartStore.state.basket].info.name"
26
+ required="true"
27
+ inputmode="text"
28
+ class="viur-shop-cart-headline"
29
+ >
30
+ <sl-icon library="hsk" name="pen" slot="suffix"></sl-icon>
31
+ </sl-input>
32
+ </div>
33
+ <sl-dropdown distance="10">
34
+ <sl-icon
35
+ class="dots"
36
+ name="dots"
37
+ library="hsk"
38
+ slot="trigger"
39
+ ></sl-icon>
40
+ <sl-menu>
41
+ <sl-menu-item @click="saveCart" title="Warenkorb speichern">
42
+ <sl-icon
43
+ slot="prefix"
44
+ library="hsk"
45
+ name="save"
46
+ class="primary-icon"
47
+ ></sl-icon>
48
+ Warenkorb speichern
49
+ </sl-menu-item>
50
+ <sl-menu-item @click="saveCart" title="Zu Projekt hinzufügen">
51
+ <sl-icon
52
+ slot="prefix"
53
+ library="hsk"
54
+ name="project"
55
+ class="primary-icon"
56
+ ></sl-icon>
57
+ Zu Projekt hinzufügen
58
+ </sl-menu-item>
59
+ <sl-menu-item @click="saveCart" title="Warenkorb kopieren">
60
+ <sl-icon
61
+ slot="prefix"
62
+ library="hsk"
63
+ name="clone"
64
+ class="primary-icon"
65
+ ></sl-icon>
66
+ Warenkorb kopieren
67
+ </sl-menu-item>
68
+ <sl-menu-item @click="saveCart" title="Warenkorb löschen">
69
+ <sl-icon
70
+ slot="prefix"
71
+ library="hsk"
72
+ name="delete"
73
+ class="delete-icon"
74
+ ></sl-icon>
75
+ Warenkorb löschen
76
+ </sl-menu-item>
77
+ </sl-menu>
78
+ </sl-dropdown>
79
+ </div>
80
+ <sl-input
81
+ v-if="mode !== 'basket'"
82
+ name="cart-internalCartNo"
83
+ placeholder="Freifeld (Kommission)"
84
+ v-model="
85
+ cartStore.state.carts[cartStore.state.basket].info.customer_comment
86
+ "
87
+ inputmode="text"
88
+ class="viur-shop-cart-descr"
89
+ >
90
+ <sl-icon library="hsk" name="pen" slot="suffix"></sl-icon>
91
+ </sl-input>
92
+ <br />
93
+ <sl-alert
94
+ ref="cartActionInfo"
95
+ variant="primary"
96
+ duration="3000"
97
+ closable
98
+ >
99
+ <sl-icon slot="icon" name="check"></sl-icon>
100
+ <strong>Warenkorb gespeichert!</strong><br />
101
+ </sl-alert>
102
+ <sl-alert ref="cartErrorInfo" variant="danger" duration="3000" closable>
103
+ <sl-icon slot="icon" name="error"></sl-icon>
104
+ <strong>Warenkorb nicht gespeichert!</strong><br />
105
+ </sl-alert>
106
+
107
+ <sl-spinner v-if="!state.itemsIsInit"></sl-spinner>
108
+
109
+ <template v-else>
110
+ <sl-card
111
+ horizontal
112
+ class="viur-shop-cart-card"
113
+ v-for="item in cartStore.state.carts[cartStore.state.basket].items"
114
+ >
115
+ <img
116
+ class="viur-shop-cart-card-img"
117
+ slot="image"
118
+ :src="getImage(item.article.dest.key)"
119
+ />
120
+ <div class="viur-shop-cart-card-header" slot="header">
121
+ <h4 class="viur-shop-cart-card-headline headline">
122
+ {{ item.article.dest.shop_name }} | 425018
123
+ </h4>
124
+ </div>
125
+ <div class="viur-shop-cart-card-body-row">
126
+ <div class="viur-shop-cart-card-body-info">
127
+ <div class="viur-shop-cart-card-descr">
128
+ Version: 900x900x2000 <br />
129
+ Farbe: Chromoptik <br />
130
+ Glasart: Klar hell mit Edelglasbeschichtung<br />
131
+ Anschlag: Beidseitig variabel<br />
132
+ Griff: Stangengriff Exklusiv (56)
133
+ </div>
134
+ <div class="viur-shop-cart-card-body-footer">
135
+ <sl-button
136
+ size="small"
137
+ outline
138
+ class="viur-shop-cart-card-add-to-favourites-btn"
139
+ variant="primary"
140
+ title="Add to favourites"
141
+ >
142
+ <sl-icon name="heart" slot="prefix"></sl-icon>
143
+ </sl-button>
144
+ <sl-button
145
+ size="small"
146
+ outline
147
+ class="viur-shop-cart-card-delete-btn"
148
+ variant="primary"
149
+ title="Remove from cart"
150
+ @click="
151
+ removeItem(
152
+ item,
153
+ item.article.dest.key,
154
+ cartStore.state.basket,
155
+ )
156
+ "
157
+ >
158
+ <sl-icon name="trash" slot="prefix"></sl-icon>
159
+ </sl-button>
160
+ </div>
161
+ </div>
162
+ <div class="viur-shop-cart-card-body-amount">
163
+ <sl-input
164
+ class="amount-input"
165
+ type="number"
166
+ label="Anzahl"
167
+ placeholder="Number"
168
+ min="0"
169
+ v-model="item.quantity"
170
+ @input="
171
+ updateItem(
172
+ item,
173
+ item.article.dest.key,
174
+ cartStore.state.basket,
175
+ item.quantity,
176
+ )
177
+ "
178
+ >
179
+ </sl-input>
180
+ </div>
181
+ <div class="viur-shop-cart-card-price-wrap" slot="footer">
182
+ <div class="viur-shop-cart-card-price-label">Preis</div>
183
+ <div class="viur-shop-cart-card-price">
184
+ {{ item.price.retail }}
185
+
186
+ </div>
187
+ <div class="viur-shop-cart-card-small-print">Brutto / Stk.</div>
188
+ </div>
189
+ </div>
190
+ </sl-card>
191
+ </template>
192
+ </div>
193
+
194
+ <teleport to="#order_sidebar" v-if="sidebar">
195
+ <h2 class="viur-shop-cart-sidebar-headline headline">Zusammenfassung</h2>
196
+ <br />
197
+
198
+ <sl-input label="Rabattcode eingeben"></sl-input>
199
+ <br />
200
+
201
+ <div class="viur-shop-cart-sidebar-info-line">
202
+ <span>Zwischensumme</span>
203
+ <!-- TODO: Preis in shop modul muss trotzdem ohne rabatt sein - extra feld für rabattierten preis und rabatt müssen ebenfalls hier sichtbar werden -->
204
+ {{ cartStore.state.carts[cartStore.state.basket].info.total }} €
205
+ </div>
206
+ <div class="viur-shop-cart-sidebar-info-line">
207
+ <span>Rabatt</span>
208
+ 0 €
209
+ </div>
210
+ <div class="viur-shop-cart-sidebar-info-line">
211
+ <span>Versandkosten</span>
212
+ 0 €
213
+ </div>
214
+ <div class="viur-shop-cart-sidebar-info-line total">
215
+ <span>Gesamt:</span>
216
+ {{ cartStore.state.carts[cartStore.state.basket].info.total }} €
217
+ </div>
218
+ <div class="viur-shop-cart-sidebar-btn-wrap">
219
+ <sl-button variant="info" size="small"> Jetzt Bestellen </sl-button>
220
+ <sl-button size="small" variant="primary">
221
+ <sl-icon name="paypal" slot="prefix"></sl-icon>
222
+ Paypal
223
+ </sl-button>
224
+ </div>
225
+ </teleport>
226
+ </div>
227
+ </template>
228
+ </template>
229
+
230
+ <script setup>
231
+ import { reactive, computed, onBeforeMount, ref } from "vue";
232
+ import Loader from "@viur/vue-utils/generic/Loader.vue";
233
+ import { useCartStore } from "../../stores/cart.js";
234
+ import { Request } from "@viur/vue-utils";
235
+
236
+ const props = defineProps({
237
+ mode: { type: String, default: "basket" },
238
+ cartKey: { type: String, default: "" },
239
+ sidebar: { type: Boolean, default: true },
240
+ });
241
+
242
+ const cartStore = useCartStore();
243
+
244
+ const confirm = ref(null);
245
+
246
+ const state = reactive({
247
+ cartIsInit: computed(() => {
248
+ return cartStore.state.basket.length ? true : false;
249
+ }),
250
+ itemsIsInit: computed(() => {
251
+ return cartStore.state.carts[cartStore.state.basket].items ? true : false;
252
+ }),
253
+ images: {},
254
+ currentItem: {},
255
+ });
256
+
257
+ const currentCartKey = computed(() => {
258
+ return props.mode === "basket" ? cartStore.state.basket : props.cartKey;
259
+ });
260
+
261
+ function getImage(item) {
262
+ Request.get(`/json/dk_variante/view/${item}`).then(async (resp) => {
263
+ let data = await resp.json();
264
+
265
+ data = data.values;
266
+
267
+ let imageUrl = data.dk_artikel.dest.image
268
+ ? Request.downloadUrlFor(data.dk_artikel.dest.image)
269
+ : "https://images.unsplash.com/photo-1559209172-0ff8f6d49ff7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=80";
270
+
271
+ state.images[item] = imageUrl;
272
+ });
273
+
274
+ return state.images[item];
275
+ }
276
+
277
+ async function onConfirm() {
278
+ await cartStore.updateItem(
279
+ state.currentItem.article.dest.key,
280
+ cartStore.state.basket,
281
+ 0,
282
+ );
283
+ confirm.value.hide();
284
+ }
285
+
286
+ function updateItem(item, articleKey, cartKey, quantity) {
287
+ if (quantity === 0) {
288
+ confirm.value.show();
289
+ state.currentItem = item;
290
+ } else {
291
+ cartStore.updateItem(articleKey, cartKey, quantity);
292
+ }
293
+ }
294
+
295
+ function removeItem(item, articleKey, cartKey) {
296
+ confirm.value.show();
297
+ state.currentItem = item;
298
+ }
299
+
300
+ function onDialogHide() {
301
+ cartStore.state.carts[cartStore.state.basket].items.forEach((item) => {
302
+ if (item.key === state.currentItem.key) {
303
+ item.quantity = 1;
304
+ }
305
+ });
306
+ state.currentItem = {};
307
+ }
308
+
309
+ onBeforeMount(async () => {
310
+ await cartStore.init();
311
+ });
312
+ </script>
313
+
314
+ <style scoped>
315
+ .viur-shop-cart-wrap {
316
+ flex-direction: row;
317
+ gap: var(--sl-spacing-x-large);
318
+ align-items: flex-start;
319
+ }
320
+
321
+ .viur-shop-cart-sidebar-btn-wrap {
322
+ display: flex;
323
+ flex-direction: column;
324
+ margin-top: var(--sl-spacing-large);
325
+
326
+ sl-button {
327
+ margin-bottom: var(--sl-spacing-x-small);
328
+ }
329
+ }
330
+
331
+ sl-alert {
332
+ margin-top: var(--sl-spacing-medium);
333
+ margin-bottom: var(--sl-spacing-medium);
334
+ }
335
+
336
+ .viur-shop-cart-controlbar {
337
+ width: 100%;
338
+ display: flex;
339
+ justify-content: space-between;
340
+ align-items: center;
341
+
342
+ sl-input {
343
+ flex: 1;
344
+
345
+ &::part(base) {
346
+ margin-bottom: 0;
347
+ }
348
+ }
349
+ }
350
+
351
+ .viur-shop-cart-button-list {
352
+ display: flex;
353
+ flex-direction: row;
354
+ gap: 10px;
355
+
356
+ &.left {
357
+ flex: 1;
358
+ margin-right: 10px;
359
+ }
360
+ }
361
+
362
+ .search {
363
+ flex: 1 1 100%;
364
+ margin-left: 10px;
365
+ }
366
+
367
+ .article-combobox {
368
+ float: left;
369
+ width: 75ch;
370
+ }
371
+
372
+ .viur-shop-cart-card-img {
373
+ aspect-ratio: 1;
374
+ }
375
+
376
+ .viur-shop-cart-selection {
377
+ flex: 1;
378
+ }
379
+
380
+ .cart-wrap {
381
+ display: flex;
382
+ flex-direction: column;
383
+ width: 100%;
384
+ }
385
+
386
+ .soma-input {
387
+ display: grid;
388
+ grid-template-columns: 120px 1fr;
389
+ align-items: center;
390
+ }
391
+
392
+ .soma-label {
393
+ display: flex;
394
+ flex-direction: row;
395
+ align-items: center;
396
+
397
+ sl-icon {
398
+ margin-left: 5px;
399
+ background-color: @highlightColor;
400
+ color: #fff;
401
+ aspect-ratio: 1;
402
+ border-radius: 50%;
403
+ padding: 0.3em;
404
+ font-size: 0.6em;
405
+ cursor: pointer;
406
+ }
407
+ }
408
+
409
+ sl-tooltip {
410
+ &::part(body) {
411
+ line-height: 1.2;
412
+ font-weight: 400;
413
+ padding: 10px;
414
+ }
415
+ }
416
+
417
+ .cart-tab {
418
+ sl-tab {
419
+ width: 25%;
420
+
421
+ &::part(base) {
422
+ width: 100%;
423
+ height: 100%;
424
+ display: flex;
425
+ justify-content: center;
426
+ align-items: center;
427
+ position: relative;
428
+ color: var(--sl-color-neutral-400);
429
+ }
430
+
431
+ &[aria-selected="true"]::part(base) {
432
+ color: var(--ignt-color-primary) !important;
433
+ }
434
+ }
435
+ }
436
+
437
+ .cart-status-text {
438
+ font-size: 0.8em;
439
+ color: inherit;
440
+ text-align: center;
441
+ margin-top: 0.6em;
442
+ white-space: initial;
443
+ }
444
+
445
+ .search-box {
446
+ display: flex;
447
+ flex-direction: row;
448
+ flex-wrap: nowrap;
449
+ align-items: stretch;
450
+ margin-bottom: 30px;
451
+
452
+ sl-button {
453
+ &::part(base) {
454
+ height: 100%;
455
+ }
456
+ }
457
+
458
+ @media (--ignt-mq-max-break-medium) {
459
+ flex-wrap: wrap;
460
+ }
461
+ }
462
+
463
+ .article-combobox {
464
+ flex: 1 1 100%;
465
+ margin-bottom: 10px;
466
+
467
+ &::part(base) {
468
+ margin-bottom: 0;
469
+ }
470
+
471
+ @media (--ignt-mq-max-break-medium) {
472
+ margin-bottom: 0;
473
+ }
474
+ }
475
+
476
+ .comission-box {
477
+ margin-right: 10px;
478
+
479
+ &::part(base) {
480
+ margin-bottom: 0;
481
+ }
482
+
483
+ @media (--ignt-mq-max-break-medium) {
484
+ flex: 1;
485
+ }
486
+ }
487
+
488
+ .search-amt {
489
+ margin-right: 10px;
490
+
491
+ &::part(base) {
492
+ margin-bottom: 0;
493
+ width: 80px;
494
+ }
495
+ }
496
+
497
+ .viur-shop-cart-headline {
498
+ &::part(base) {
499
+ background-color: transparent;
500
+ transition: all ease 0.3s;
501
+ border-bottom: 1px solid transparent;
502
+ height: auto;
503
+ }
504
+
505
+ :deep(.input--focused) {
506
+ border-bottom: 1px solid var(--sl-color-primary-500) !important;
507
+ }
508
+
509
+ &::part(input) {
510
+ color: var(--sl-color-primary-500);
511
+ font-weight: 300;
512
+ text-transform: uppercase;
513
+ font-size: 1.85em;
514
+ padding: 0.1em 0;
515
+ height: auto;
516
+ }
517
+
518
+ &::part(suffix) {
519
+ pointer-events: none;
520
+ width: 1.5em;
521
+ margin-left: -1em;
522
+ font-size: 1.5em;
523
+ }
524
+
525
+ &:hover {
526
+ &::part(base) {
527
+ border-bottom: 1px solid var(--sl-color-primary-500);
528
+ }
529
+ }
530
+ }
531
+
532
+ .viur-shop-cart-descr {
533
+ margin-top: 10px;
534
+
535
+ &::part(base) {
536
+ background-color: transparent;
537
+ transition: all ease 0.3s;
538
+ border-bottom: 1px solid transparent;
539
+ margin-bottom: 0;
540
+ }
541
+
542
+ &::part(input) {
543
+ padding: 0.1em 0;
544
+ height: auto;
545
+ color: var(--ignt-color-text);
546
+ }
547
+
548
+ &::part(suffix) {
549
+ pointer-events: none;
550
+ width: 1.5em;
551
+ margin-left: -1em;
552
+ font-size: 1.5em;
553
+ }
554
+
555
+ &:hover {
556
+ &::part(base) {
557
+ border-bottom: 1px solid var(--ignt-color-text);
558
+ }
559
+ }
560
+ }
561
+
562
+ sl-menu-item {
563
+ &::part(base) {
564
+ padding: 0.2em 0.9em 0.2em 0.8em;
565
+ }
566
+
567
+ &::part(checked-icon) {
568
+ display: none;
569
+ }
570
+
571
+ &::part(prefix) {
572
+ margin-right: 10px;
573
+ }
574
+
575
+ &::part(suffix) {
576
+ margin-right: -1.5em;
577
+ }
578
+ }
579
+
580
+ .primary-icon {
581
+ color: var(--ignt-color-primary);
582
+ }
583
+
584
+ .delete-icon {
585
+ color: @warnColor;
586
+ }
587
+
588
+ .dots {
589
+ color: var(--ignt-color-primary);
590
+ width: 1.5em;
591
+ height: 100%;
592
+ font-size: 1em;
593
+ padding: 0.4em;
594
+ }
595
+
596
+ .viur-shop-cart-sidebar-info-line {
597
+ display: flex;
598
+ flex-direction: row;
599
+ flex-wrap: nowrap;
600
+ margin: var(--sl-spacing-2x-small) 0;
601
+
602
+ &.total {
603
+ font-weight: 600;
604
+ border-top: 1px solid var(--sl-color-neutral-300);
605
+ border-bottom: 1px solid var(--sl-color-neutral-300);
606
+ padding: var(--sl-spacing-x-small) 0;
607
+ margin: var(--sl-spacing-small) 0;
608
+ }
609
+
610
+ span {
611
+ margin-right: auto;
612
+ }
613
+ }
614
+
615
+ .viur-shop-cart-card {
616
+ margin-bottom: var(--sl-spacing-x-large);
617
+
618
+ &::part(header) {
619
+ border-bottom: none;
620
+ padding-top: 0;
621
+ padding-right: 0;
622
+ }
623
+
624
+ &::part(image) {
625
+ flex-basis: 25%;
626
+ max-width: 250px;
627
+ }
628
+
629
+ &::part(body) {
630
+ display: flex;
631
+ flex: 1;
632
+ padding-top: 0;
633
+ padding-bottom: 0;
634
+ padding-right: 0;
635
+ }
636
+
637
+ &::part(group) {
638
+ padding: var(--sl-spacing-small) 0;
639
+ }
640
+ }
641
+
642
+ .viur-shop-cart-card-body-row {
643
+ display: grid;
644
+ grid-template-columns: 1fr auto auto;
645
+ gap: var(--sl-spacing-large);
646
+ flex: 1;
647
+ }
648
+
649
+ .viur-shop-cart-card-body-info {
650
+ display: flex;
651
+ flex-direction: column;
652
+ height: 100%;
653
+ }
654
+
655
+ .viur-shop-cart-card-descr {
656
+ margin-bottom: auto;
657
+ }
658
+
659
+ .viur-shop-cart-card-body-footer {
660
+ display: flex;
661
+ flex-direction: row;
662
+ gap: var(--sl-spacing-2x-small);
663
+ margin-top: var(--sl-spacing-large);
664
+ }
665
+
666
+ .amount-input {
667
+ width: 5em;
668
+ }
669
+
670
+ .viur-shop-cart-card-price-wrap {
671
+ display: flex;
672
+ flex-direction: column;
673
+
674
+ .viur-shop-cart-card-small-print {
675
+ font-size: 0.75em;
676
+ margin-left: auto;
677
+ }
678
+ }
679
+
680
+ .viur-shop-cart-card-price {
681
+ font-size: 1.3em;
682
+ }
683
+
684
+ .viur-shop-cart-card-price-label {
685
+ color: var(--ignt-color-primary);
686
+ font-weight: 600;
687
+ margin-bottom: 10px;
688
+ font-size: 1em;
689
+ margin-left: auto;
690
+ }
691
+ </style>