@viur/shop-components 0.14.6 → 0.14.8
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
package/src/ShopOrderStepper.vue
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
ref="stepper"
|
|
4
4
|
class="viur-shop-order-tabgroup"
|
|
5
5
|
no-scroll-controls
|
|
6
|
+
:data-steppervisible="shopStore.state.stepperVisible"
|
|
6
7
|
>
|
|
7
8
|
<template v-for="(tab,name) in shopStore.state.tabs">
|
|
8
9
|
<StepperTab
|
|
9
|
-
v-show="shopStore.state.
|
|
10
|
+
v-show="shopStore.state.stepperVisible"
|
|
10
11
|
:tab="name"
|
|
11
12
|
>
|
|
12
13
|
</StepperTab>
|
|
@@ -106,4 +107,8 @@ sl-tab-panel {
|
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
.viur-shop-order-tabgroup[data-steppervisible='false']::part(nav){
|
|
111
|
+
visibility: hidden;
|
|
112
|
+
}
|
|
113
|
+
|
|
109
114
|
</style>
|
package/src/Steps/ShopCart.vue
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
:nextfunction="nextStep"
|
|
6
6
|
>
|
|
7
7
|
</slot>
|
|
8
|
-
<loading-handler :isLoading="
|
|
8
|
+
<loading-handler :isLoading="shopStore.state.cartIsLoading" :isUpdating="shopStore.state.cartIsLoading">
|
|
9
9
|
<div class="viur-shop-item-wrapper" v-if="state.items.length>0">
|
|
10
10
|
<cart-item v-for="item in state.items" :item="item"
|
|
11
11
|
:edit="!shopStore.state.order?.['is_checkout_in_progress']"
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
</sl-card>
|
|
88
|
-
<div class="loading" v-if="
|
|
88
|
+
<div class="loading" v-if="shopStore.state.cartIsUpdating">
|
|
89
89
|
<sl-spinner></sl-spinner>
|
|
90
90
|
</div>
|
|
91
91
|
</div>
|
|
@@ -96,7 +96,8 @@ import { getImage } from '../utils';
|
|
|
96
96
|
import { useCart } from '../composables/cart';
|
|
97
97
|
import dialogButton from './dialogButton.vue';
|
|
98
98
|
import PriceBox from "./PriceBox.vue";
|
|
99
|
-
|
|
99
|
+
import { useViurShopStore } from "../shop";
|
|
100
|
+
const shopStore = useViurShopStore()
|
|
100
101
|
const {addItem, removeItem, state:cartState, getValue} = useCart()
|
|
101
102
|
|
|
102
103
|
const changeAmount = useDebounceFn((amount) => {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<price-box :item="item" :amount="item.quantity" :retail="false"></price-box>
|
|
62
62
|
</div>
|
|
63
63
|
</sl-card>
|
|
64
|
-
<div class="loading" v-if="
|
|
64
|
+
<div class="loading" v-if="shopStore.state.cartIsUpdating">
|
|
65
65
|
<sl-spinner></sl-spinner>
|
|
66
66
|
</div>
|
|
67
67
|
</div>
|
|
@@ -72,7 +72,8 @@ import { getImage } from '../utils';
|
|
|
72
72
|
import { useCart } from '../composables/cart';
|
|
73
73
|
import dialogButton from './dialogButton.vue';
|
|
74
74
|
import PriceBox from "./PriceBox.vue";
|
|
75
|
-
|
|
75
|
+
import { useViurShopStore } from "../shop";
|
|
76
|
+
const shopStore = useViurShopStore()
|
|
76
77
|
const {addItem, removeItem, state:cartState, getValue} = useCart()
|
|
77
78
|
|
|
78
79
|
const changeAmount = useDebounceFn((amount) => {
|
|
@@ -96,7 +96,12 @@ export const useAddress = defineStore('useAddressStore', () => {
|
|
|
96
96
|
// The address skel is the same, we just need to reload the relation
|
|
97
97
|
fetchCart();
|
|
98
98
|
} else {
|
|
99
|
-
await updateCart({shipping_address_key: key});
|
|
99
|
+
let resp = await updateCart({shipping_address_key: key});
|
|
100
|
+
const data = await resp.json()
|
|
101
|
+
shopStore.state.cartRoot['shipping_address'] = data['shipping_address']
|
|
102
|
+
if (shopStore.state.cartRoot.discount){
|
|
103
|
+
shopStore.state.discounts = {[shopStore.state.cartRoot.discount.dest.key]:shopStore.state.cartRoot.discount}
|
|
104
|
+
}
|
|
100
105
|
}
|
|
101
106
|
} else if (type === 'billing') {
|
|
102
107
|
const {addOrUpdateOrder, fetchOrder, billingAddressKey} = useOrder();
|
package/src/composables/cart.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {computed, reactive} from 'vue';
|
|
1
|
+
import {computed, reactive, watch} from 'vue';
|
|
2
2
|
import {Request} from '@viur/vue-utils'
|
|
3
3
|
import { removeUndefinedValues} from '../utils'
|
|
4
4
|
|
|
@@ -7,8 +7,8 @@ import { useViurShopStore } from '../shop'
|
|
|
7
7
|
export function useCart() {
|
|
8
8
|
const shopStore = useViurShopStore()
|
|
9
9
|
const state = reactive({
|
|
10
|
-
isLoading:
|
|
11
|
-
isUpdating:
|
|
10
|
+
isLoading:computed(()=>shopStore.state.cartIsLoading), // not used anymore
|
|
11
|
+
isUpdating:computed(()=>shopStore.state.cartIsUpdating)// not used anymore
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
function getValue(value){
|
|
@@ -37,14 +37,13 @@ export function useCart() {
|
|
|
37
37
|
|
|
38
38
|
function fetchCart() {
|
|
39
39
|
//first fetch root then fetchItems for this root
|
|
40
|
-
state.
|
|
41
|
-
|
|
40
|
+
shopStore.state.cartIsLoading = true;
|
|
42
41
|
if (shopStore.state.order != null && shopStore.state.order?.cart?.dest.key) {
|
|
43
42
|
// shopStore.state.cartRoot = {};
|
|
44
43
|
shopStore.state.cartRoot = shopStore.state.order.cart.dest;
|
|
45
44
|
|
|
46
45
|
return fetchCartItems(shopStore.state.cartRoot["key"]).then(() => { // TODO: duplicate code
|
|
47
|
-
state.
|
|
46
|
+
shopStore.state.cartIsLoading = false;
|
|
48
47
|
shopStore.state.cartReady = true;
|
|
49
48
|
});
|
|
50
49
|
}
|
|
@@ -52,7 +51,7 @@ export function useCart() {
|
|
|
52
51
|
return fetchCartRoot().then(() => {
|
|
53
52
|
if (!shopStore.state.cartRoot?.["key"]) return 0;
|
|
54
53
|
fetchCartItems(shopStore.state.cartRoot["key"]).then(() => { // TODO: duplicate code
|
|
55
|
-
state.
|
|
54
|
+
shopStore.state.cartIsLoading = false;
|
|
56
55
|
shopStore.state.cartReady = true;
|
|
57
56
|
});
|
|
58
57
|
});
|
|
@@ -136,25 +135,25 @@ export function useCart() {
|
|
|
136
135
|
|
|
137
136
|
function addItem(key, quantity=1, cart=null, quantity_mode='replace'){
|
|
138
137
|
//add Item to cart
|
|
139
|
-
state.
|
|
138
|
+
shopStore.state.cartIsUpdating = true
|
|
140
139
|
return Request.post(`${shopStore.state.shopApiUrl}/article_add`, {dataObj:{
|
|
141
140
|
article_key: key,
|
|
142
141
|
parent_cart_key:cart?cart:shopStore.state.cartRoot['key'],
|
|
143
142
|
quantity:quantity,
|
|
144
143
|
quantity_mode:quantity_mode
|
|
145
144
|
}}).then(async (resp)=>{
|
|
146
|
-
state.
|
|
145
|
+
shopStore.state.cartIsUpdating=false
|
|
147
146
|
fetchCart()
|
|
148
147
|
})
|
|
149
148
|
|
|
150
149
|
}
|
|
151
150
|
function removeItem(key, cart=null){
|
|
152
|
-
state.
|
|
151
|
+
shopStore.state.cartIsUpdating = true
|
|
153
152
|
return Request.post(`${shopStore.state.shopApiUrl}/article_remove`, {dataObj:{
|
|
154
153
|
article_key: key,
|
|
155
154
|
parent_cart_key:cart?cart:shopStore.state.cartRoot['key']
|
|
156
155
|
}}).then(async (resp)=>{
|
|
157
|
-
state.
|
|
156
|
+
shopStore.state.cartIsUpdating=false
|
|
158
157
|
fetchCart()
|
|
159
158
|
})
|
|
160
159
|
}
|
package/src/shop.js
CHANGED
|
@@ -103,7 +103,8 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
|
|
|
103
103
|
stepperLength:computed(()=>{
|
|
104
104
|
return Object.keys(state.tabs).length
|
|
105
105
|
}),
|
|
106
|
-
|
|
106
|
+
cartIsUpdating:false,
|
|
107
|
+
cartIsLoading:false,
|
|
107
108
|
// SHOP DATA
|
|
108
109
|
cartList:[], //articles in cart
|
|
109
110
|
cartRoot:null, //actual cart rootnode entry ( used for shipping etc)
|
|
@@ -125,7 +126,13 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
|
|
|
125
126
|
paymentProviderData:null,
|
|
126
127
|
UserDataLayout: shallowRef(AddressFormLayout),
|
|
127
128
|
discounts:{},
|
|
128
|
-
stepperActionComponent:shallowRef(ShopOrderStepperAction)
|
|
129
|
+
stepperActionComponent:shallowRef(ShopOrderStepperAction),
|
|
130
|
+
|
|
131
|
+
//stepper rules:
|
|
132
|
+
stepperVisible: computed(()=>{
|
|
133
|
+
return state.currentTab!=='complete'
|
|
134
|
+
})
|
|
135
|
+
|
|
129
136
|
})
|
|
130
137
|
|
|
131
138
|
function addTab({name, component, displayname, iconname, iconlibrary,active})
|