@viur/shop-components 0.0.1-dev.11 → 0.0.1-dev.12
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
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<pre
|
|
2
|
+
<pre> {{ state.nodes }}</pre>
|
|
3
|
+
<pre> {{ state.leaves }}</pre>
|
|
4
|
+
<!-- <CartNode></CartNode>
|
|
5
|
+
<CartLeaf></CartLeaf> -->
|
|
4
6
|
<!-- <template v-else>
|
|
5
7
|
<div class="bind viur-shop-cart-wrap">
|
|
6
8
|
<sl-dialog ref="confirm" @sl-hide="onDialogHide">
|
|
@@ -233,11 +235,12 @@
|
|
|
233
235
|
import { reactive, computed, onBeforeMount, ref } from "vue";
|
|
234
236
|
import Loader from "@viur/vue-utils/generic/Loader.vue";
|
|
235
237
|
import { useCartStore } from "../../stores/cart.js";
|
|
236
|
-
import
|
|
238
|
+
import CartNode from "./CartNode.vue";
|
|
239
|
+
import CartLeaf from "./CartLeaf.vue";
|
|
237
240
|
|
|
238
241
|
const props = defineProps({
|
|
239
242
|
mode: { type: String, default: "basket" },
|
|
240
|
-
cartKey: { type: String,
|
|
243
|
+
cartKey: { type: String, required: true },
|
|
241
244
|
sidebar: { type: Boolean, default: true },
|
|
242
245
|
});
|
|
243
246
|
|
|
@@ -254,6 +257,8 @@ const state = reactive({
|
|
|
254
257
|
}),
|
|
255
258
|
images: {},
|
|
256
259
|
currentItem: {},
|
|
260
|
+
nodes: [],
|
|
261
|
+
leaves: {},
|
|
257
262
|
});
|
|
258
263
|
|
|
259
264
|
const currentCartKey = computed(() => {
|
|
@@ -308,8 +313,29 @@ function onDialogHide() {
|
|
|
308
313
|
state.currentItem = {};
|
|
309
314
|
}
|
|
310
315
|
|
|
316
|
+
async function getChildren(parentKey = props.key) {
|
|
317
|
+
const children = await cartStore.getChildren(parentKey);
|
|
318
|
+
|
|
319
|
+
children.forEach(async (child) => {
|
|
320
|
+
if (child.skel_type === "node") {
|
|
321
|
+
state.nodes.push(child);
|
|
322
|
+
await getChildren(child.key);
|
|
323
|
+
} else {
|
|
324
|
+
if (!Object.keys(state.leaves).includes(parentKey)) {
|
|
325
|
+
state.leaves[parentKey] = [];
|
|
326
|
+
}
|
|
327
|
+
state.leaves[parentKey].push(child);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
311
332
|
onBeforeMount(async () => {
|
|
312
333
|
await cartStore.init();
|
|
334
|
+
await getChildren();
|
|
335
|
+
|
|
336
|
+
console.log("state.nodes", state.nodes);
|
|
337
|
+
|
|
338
|
+
console.log("state.leaves", state.leaves);
|
|
313
339
|
});
|
|
314
340
|
</script>
|
|
315
341
|
|
|
@@ -21,7 +21,11 @@ const state = reactive({
|
|
|
21
21
|
tabs: {
|
|
22
22
|
cart: {
|
|
23
23
|
component: shallowRef(CartView),
|
|
24
|
-
props: {
|
|
24
|
+
props: {
|
|
25
|
+
sidebar: true,
|
|
26
|
+
mode: "basket",
|
|
27
|
+
cartKey: cartStore.state.basketRootNode.key,
|
|
28
|
+
}, // cartKey (on initial call has to be a root node) is a required prop, make sure that cartStore.init() is called before cart is mounted
|
|
25
29
|
displayName: "Warenkorb",
|
|
26
30
|
icon: { name: "cart", library: "hsk" },
|
|
27
31
|
position: 2,
|
|
@@ -95,6 +99,7 @@ function handleTabs(e) {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
onBeforeMount(async () => {
|
|
102
|
+
await cartStore.init();
|
|
98
103
|
await cartStore.getAdressStructure();
|
|
99
104
|
});
|
|
100
105
|
</script>
|