@lancom/shared 0.0.301 → 0.0.302
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/assets/scss/_common.scss +4 -0
- package/components/editor/editor.vue +6 -10
- package/components/editor/editor_layers/editor-layers.scss +5 -0
- package/components/editor/editor_layers/editor-layers.vue +13 -5
- package/components/editor/editor_product_details/editor-product-details.vue +1 -0
- package/components/editor/editor_workspace/editor-workspace.vue +1 -0
- package/components/editor/mobile_editor_product_details/mobile-editor-product-details.vue +23 -19
- package/components/order/order_view/order-view.vue +4 -1
- package/components/product/add-to-cart-btn.vue +18 -0
- package/components/product/editor_pricing/editor-pricing.vue +6 -8
- package/components/products/product_list_product/product-list-product.scss +5 -0
- package/components/products/product_list_product/product-list-product.vue +11 -1
- package/mixins/add-to-cart.js +34 -21
- package/package.json +1 -1
- package/store/cart.js +7 -2
- package/store/product.js +1 -1
- package/store/products.js +8 -0
package/assets/scss/_common.scss
CHANGED
|
@@ -31,12 +31,8 @@
|
|
|
31
31
|
:delay="{ hide: 400, show: 400 }"
|
|
32
32
|
:disabled="!addToCartDisabled"
|
|
33
33
|
class="Editor__add-to-cart">
|
|
34
|
-
<btn
|
|
35
|
-
|
|
36
|
-
btn-label="Add to cart"
|
|
37
|
-
:btn-disabled="addToCartDisabled"
|
|
38
|
-
class="Editor__add-to-cart-button"
|
|
39
|
-
@onclick="proceedToCard" />
|
|
34
|
+
<add-to-cart-btn
|
|
35
|
+
class="Editor__add-to-cart-button" />
|
|
40
36
|
<template slot="popover">
|
|
41
37
|
<p>
|
|
42
38
|
You've not added any text or art to print. We only sell custom printed products. <br />
|
|
@@ -76,9 +72,7 @@
|
|
|
76
72
|
name="sm"
|
|
77
73
|
mode="down">
|
|
78
74
|
<client-only>
|
|
79
|
-
<mobile-editor-product-details
|
|
80
|
-
:add-to-cart-disabled="addToCartDisabled"
|
|
81
|
-
@add-to-cart="proceedToCard" />
|
|
75
|
+
<mobile-editor-product-details />
|
|
82
76
|
</client-only>
|
|
83
77
|
</breakpoint>
|
|
84
78
|
</div>
|
|
@@ -97,6 +91,7 @@ import MobileEditorProductDetails from './mobile_editor_product_details/mobile-e
|
|
|
97
91
|
import EditorLayers from './editor_layers/editor-layers';
|
|
98
92
|
import EditorWizard from './editor_wizard/editor-wizard';
|
|
99
93
|
import addToCartMixin from '@lancom/shared/mixins/add-to-cart';
|
|
94
|
+
import AddToCartBtn from '@lancom/shared/components/product/add-to-cart-btn';
|
|
100
95
|
|
|
101
96
|
const MIN_SCREEN_AMOUNT = 125;
|
|
102
97
|
|
|
@@ -109,7 +104,8 @@ export default {
|
|
|
109
104
|
EditorWizard,
|
|
110
105
|
MobileEditorProductDetails,
|
|
111
106
|
ProductsListDropdown,
|
|
112
|
-
Tabs
|
|
107
|
+
Tabs,
|
|
108
|
+
AddToCartBtn
|
|
113
109
|
},
|
|
114
110
|
mixins: [
|
|
115
111
|
modals,
|
|
@@ -13,11 +13,19 @@
|
|
|
13
13
|
:layer="selectedLayer"
|
|
14
14
|
@set-layer-field="setLayerField">
|
|
15
15
|
<template v-slot:header="{ invalid }">
|
|
16
|
-
<div
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
<div class="EditorLayers__close-wrapper">
|
|
17
|
+
<div
|
|
18
|
+
class="lc_regular16 EditorLayers__close-editable"
|
|
19
|
+
@click="closeEditableLayer(invalid)">
|
|
20
|
+
<i class="icon-arrow-left EditorLayers__close-editable-icon"></i>
|
|
21
|
+
See all design layers
|
|
22
|
+
</div>
|
|
23
|
+
<div>
|
|
24
|
+
<btn
|
|
25
|
+
btn-class="green"
|
|
26
|
+
btn-label="Save"
|
|
27
|
+
@onclick="closeEditableLayer(invalid)" />
|
|
28
|
+
</div>
|
|
21
29
|
</div>
|
|
22
30
|
</template>
|
|
23
31
|
</component>
|
|
@@ -21,9 +21,14 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
<div
|
|
23
23
|
class="MobileEditorProductDetails__menu-action cart"
|
|
24
|
-
:class="{ invalidate: addToCartDisabled }"
|
|
25
|
-
@click="
|
|
26
|
-
<
|
|
24
|
+
:class="{ invalidate: addToCartDisabled || addingToCart }"
|
|
25
|
+
@click="saveToCart">
|
|
26
|
+
<spinner
|
|
27
|
+
v-if="addingToCart"
|
|
28
|
+
class="MobileEditorProductDetails__menu-action-icon" />
|
|
29
|
+
<i
|
|
30
|
+
v-else
|
|
31
|
+
class="icon-bag MobileEditorProductDetails__menu-action-icon"></i>
|
|
27
32
|
<span class="MobileEditorProductDetails__menu-action-label">
|
|
28
33
|
Add to Cart
|
|
29
34
|
</span>
|
|
@@ -60,8 +65,8 @@
|
|
|
60
65
|
@click="hide"></i>
|
|
61
66
|
</div>
|
|
62
67
|
<div class="MobileEditorProductDetails__content custom-scrollbar-container">
|
|
63
|
-
<editor-workspace v-
|
|
64
|
-
<editor-layers v-
|
|
68
|
+
<editor-workspace v-show="currentTab === 'details'" />
|
|
69
|
+
<editor-layers v-show="currentTab === 'layers'" />
|
|
65
70
|
</div>
|
|
66
71
|
</div>
|
|
67
72
|
</transition-group>
|
|
@@ -71,41 +76,36 @@
|
|
|
71
76
|
<script>
|
|
72
77
|
import { createNamespacedHelpers } from 'vuex';
|
|
73
78
|
import { EventBus } from '@lancom/shared/assets/js/utils/event-bus';
|
|
79
|
+
import addToCartMixin from '@lancom/shared/mixins/add-to-cart';
|
|
74
80
|
import EditorWorkspace from '../editor_workspace/editor-workspace';
|
|
75
81
|
import EditorLayers from '../editor_layers/editor-layers';
|
|
76
82
|
|
|
77
|
-
const { mapMutations } = createNamespacedHelpers('product');
|
|
83
|
+
const { mapMutations, mapGetters } = createNamespacedHelpers('product');
|
|
78
84
|
|
|
79
85
|
export default {
|
|
80
86
|
name: 'MobileEditorProductDetails',
|
|
87
|
+
mixins: [addToCartMixin],
|
|
81
88
|
components: {
|
|
82
89
|
EditorWorkspace,
|
|
83
90
|
EditorLayers
|
|
84
91
|
},
|
|
85
|
-
props: {
|
|
86
|
-
addToCartDisabled: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
required: true
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
|
|
92
92
|
data() {
|
|
93
93
|
return {
|
|
94
94
|
isOpen: false,
|
|
95
95
|
currentTab: null
|
|
96
96
|
};
|
|
97
97
|
},
|
|
98
|
-
|
|
98
|
+
computed: {
|
|
99
|
+
...mapGetters(['selectedLayer', 'editablePrintArea'])
|
|
100
|
+
},
|
|
99
101
|
mounted() {
|
|
100
102
|
EventBus.$on('focus-on-default-product', this.focusOnDefaultProduct);
|
|
101
103
|
},
|
|
102
|
-
|
|
103
104
|
beforeDestroy() {
|
|
104
105
|
EventBus.$off('focus-on-default-product', this.focusOnDefaultProduct);
|
|
105
106
|
},
|
|
106
|
-
|
|
107
107
|
methods: {
|
|
108
|
-
...mapMutations(['setEditModeSelectedLayer']),
|
|
108
|
+
...mapMutations(['setEditModeSelectedLayer', 'removeTemplateLayer', 'setSelectedLayer']),
|
|
109
109
|
focusOnDefaultProduct() {
|
|
110
110
|
this.show('details');
|
|
111
111
|
},
|
|
@@ -126,15 +126,19 @@ export default {
|
|
|
126
126
|
});
|
|
127
127
|
},
|
|
128
128
|
hide() {
|
|
129
|
+
if (this.selectedLayer?.type === 'text' && !this.selectedLayer.copy) {
|
|
130
|
+
this.removeTemplateLayer(this.selectedLayer);
|
|
131
|
+
}
|
|
132
|
+
this.setSelectedLayer(null);
|
|
129
133
|
this.isOpen = false;
|
|
130
134
|
this.currentTab = null;
|
|
131
135
|
},
|
|
132
|
-
|
|
136
|
+
async saveToCart() {
|
|
133
137
|
if (this.addToCartDisabled) {
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
140
|
+
await this.proceedToCard();
|
|
136
141
|
this.hide();
|
|
137
|
-
this.$emit('add-to-cart');
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<h4
|
|
14
14
|
v-if="shopContacts"
|
|
15
15
|
class="lc_h4">
|
|
16
|
-
|
|
16
|
+
{{ abnLabel }}: {{ shopContacts.abn }}
|
|
17
17
|
</h4>
|
|
18
18
|
</div>
|
|
19
19
|
<div>
|
|
@@ -226,6 +226,9 @@ export default {
|
|
|
226
226
|
bsbLabel() {
|
|
227
227
|
return this.MESSAGES.DIRECT_DEPOSIT_BSB || 'BSB';
|
|
228
228
|
},
|
|
229
|
+
abnLabel() {
|
|
230
|
+
return this.MESSAGES.ABN || 'ABN';
|
|
231
|
+
},
|
|
229
232
|
}
|
|
230
233
|
};
|
|
231
234
|
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<btn
|
|
3
|
+
btn-class="green"
|
|
4
|
+
btn-label="Add to cart"
|
|
5
|
+
:btn-disabled="addToCartDisabled"
|
|
6
|
+
:btn-processing="addingToCart"
|
|
7
|
+
@onclick="proceedToCard" />
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import addToCartMixin from '@lancom/shared/mixins/add-to-cart';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
name: 'AddToCartBtn',
|
|
15
|
+
mixins: [addToCartMixin]
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
24
|
<div
|
|
25
|
-
v-else-if="hasUsedSimpleProducts && (!layers.length && isPrintPricing)"
|
|
25
|
+
v-else-if="hasUsedSimpleProducts && ((!isValidPrintOnly || !layers.length && isPrintPricing))"
|
|
26
26
|
class="EditorPricing__main-alert">
|
|
27
27
|
<img src="/images/sad.svg" />
|
|
28
28
|
No prints defined
|
|
@@ -83,13 +83,9 @@
|
|
|
83
83
|
@click="toggleDetails">
|
|
84
84
|
{{ showDetails ? 'Hide' : 'Show' }} detail
|
|
85
85
|
</div>
|
|
86
|
-
<btn
|
|
86
|
+
<add-to-cart-btn
|
|
87
87
|
v-if="hasCartBtn"
|
|
88
|
-
|
|
89
|
-
btn-label="Add to cart"
|
|
90
|
-
:btn-disabled="addToCartDisabled"
|
|
91
|
-
class="EditorPricing__add-to-cart-button"
|
|
92
|
-
@onclick="proceedToCard" />
|
|
88
|
+
class="EditorPricing__add-to-cart-button" />
|
|
93
89
|
</div>
|
|
94
90
|
</div>
|
|
95
91
|
</div>
|
|
@@ -100,6 +96,7 @@
|
|
|
100
96
|
import { mapGetters, mapActions } from 'vuex';
|
|
101
97
|
import debounce from 'lodash.debounce';
|
|
102
98
|
import { price, sizesRange, printsRange, tax } from '@lancom/shared/assets/js/utils/filters';
|
|
99
|
+
import AddToCartBtn from '@lancom/shared/components/product/add-to-cart-btn';
|
|
103
100
|
import EditorPricingDetails from '@lancom/shared/components/editor/editor_pricing/editor_pricing_details/editor-pricing-details';
|
|
104
101
|
import addToCartMixin from '@lancom/shared/mixins/add-to-cart';
|
|
105
102
|
|
|
@@ -113,7 +110,8 @@ export default {
|
|
|
113
110
|
printsRange
|
|
114
111
|
},
|
|
115
112
|
components: {
|
|
116
|
-
EditorPricingDetails
|
|
113
|
+
EditorPricingDetails,
|
|
114
|
+
AddToCartBtn
|
|
117
115
|
},
|
|
118
116
|
data() {
|
|
119
117
|
return {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<span>{{ product.gender }}</span>
|
|
40
40
|
</div> -->
|
|
41
41
|
<div
|
|
42
|
-
v-if="hasTags"
|
|
42
|
+
v-if="hasTags || product.minimumPrintOrderQuantity > 0"
|
|
43
43
|
class="ProductListProduct__tag">
|
|
44
44
|
<div
|
|
45
45
|
v-for="tag in tags"
|
|
@@ -54,6 +54,16 @@
|
|
|
54
54
|
{{ tag.name }}
|
|
55
55
|
</span>
|
|
56
56
|
</div>
|
|
57
|
+
<div
|
|
58
|
+
v-if="product.minimumPrintOrderQuantity > 0"
|
|
59
|
+
class="ProductListProduct__tag-item ProductListProduct__tag-item--qty">
|
|
60
|
+
<span>Print Minimum: {{ product.minimumPrintOrderQuantity }}</span>
|
|
61
|
+
</div>
|
|
62
|
+
<div
|
|
63
|
+
v-if="product.minimumPrintOrderQuantity > 0"
|
|
64
|
+
class="ProductListProduct__tag-item ProductListProduct__tag-item--qty">
|
|
65
|
+
<span>{{ product.printOnly ? 'No Blanks' : `Blank Minimum: ${product.minimumOrderQuantity}` }}</span>
|
|
66
|
+
</div>
|
|
57
67
|
</div>
|
|
58
68
|
</a>
|
|
59
69
|
<div class="ProductListProduct__info">
|
package/mixins/add-to-cart.js
CHANGED
|
@@ -4,7 +4,8 @@ import { generateCartProducts } from '@lancom/shared/assets/js/utils/product';
|
|
|
4
4
|
export default {
|
|
5
5
|
data() {
|
|
6
6
|
return {
|
|
7
|
-
addedToCart: false
|
|
7
|
+
addedToCart: false,
|
|
8
|
+
addingToCart: false
|
|
8
9
|
};
|
|
9
10
|
},
|
|
10
11
|
computed: {
|
|
@@ -28,6 +29,9 @@ export default {
|
|
|
28
29
|
isValidOrderQuantity() {
|
|
29
30
|
return this.isValidBigSizeOrderQuantity && this.isValidMiltipackOrderQuantity && (!this.minimumOrderQuantity || this.usedSimpleProductsQuantity >= this.minimumOrderQuantity);
|
|
30
31
|
},
|
|
32
|
+
isValidPrintOnly() {
|
|
33
|
+
return !this.product.printOnly || this.template.layers.length > 0;
|
|
34
|
+
},
|
|
31
35
|
isValidBigSizeOrderQuantity() {
|
|
32
36
|
return this.usedSimpleProductsQuantity ? ((this.usedBigSizeSimpleProductsQuantity / this.usedSimpleProductsQuantity * 100) <= 50) : true;
|
|
33
37
|
},
|
|
@@ -35,7 +39,7 @@ export default {
|
|
|
35
39
|
return !this.multipack || this.multipack.qty <= this.usedSimpleProductsQuantity;
|
|
36
40
|
},
|
|
37
41
|
addToCartDisabled() {
|
|
38
|
-
return !((this.template.layers.length || !this.isPrintPricing) && this.usedSimpleProducts.length) || this.calculatingPrice || !this.isValidOrderQuantity;
|
|
42
|
+
return !((this.template.layers.length || !this.isPrintPricing) && this.usedSimpleProducts.length) || this.calculatingPrice || !this.isValidOrderQuantity || !this.isValidPrintOnly;
|
|
39
43
|
}
|
|
40
44
|
},
|
|
41
45
|
methods: {
|
|
@@ -43,25 +47,34 @@ export default {
|
|
|
43
47
|
...mapMutations('product', ['clearTemplate', 'setIsPrintPricing']),
|
|
44
48
|
...mapMutations('layers', ['resetLayers']),
|
|
45
49
|
async proceedToCard() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
|
|
50
|
+
if (this.addingToCart || this.addToCartDisabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
this.addingToCart = true;
|
|
55
|
+
const entities = generateCartProducts(this.product, this.template.simpleProducts, this.template.layers, this.isPrintPricing, this.layerThumbnails);
|
|
56
|
+
await this.addToCart({
|
|
57
|
+
entities,
|
|
58
|
+
shop: this.shop,
|
|
59
|
+
pricing: this.productPricing,
|
|
60
|
+
country: this.country,
|
|
61
|
+
currency: this.currency
|
|
62
|
+
});
|
|
63
|
+
this.$toastr.s('Products successfully added to cart');
|
|
64
|
+
|
|
65
|
+
this.clearTemplate(true);
|
|
66
|
+
|
|
67
|
+
this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
|
|
68
|
+
|
|
69
|
+
// this.resetLayers();
|
|
70
|
+
// this.setIsPrintPricing(false);
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
this.addedToCart = true;
|
|
73
|
+
});
|
|
74
|
+
} catch (e) {
|
|
75
|
+
} finally {
|
|
76
|
+
this.addingToCart = false;
|
|
77
|
+
}
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
};
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -25,8 +25,13 @@ const getEntitiesQuantity = entities => {
|
|
|
25
25
|
const getProductsQuantities = entities => {
|
|
26
26
|
const grouped = groupBy(entities, e => e.product._id);
|
|
27
27
|
const quantities = Object.keys(grouped).map(_id => {
|
|
28
|
-
const [{ product: { name, minimumOrderQuantity } }] = grouped[_id];
|
|
29
|
-
|
|
28
|
+
const [{ prints, product: { name, minimumOrderQuantity, minimumPrintOrderQuantity } }] = grouped[_id];
|
|
29
|
+
console.log('');
|
|
30
|
+
console.log('getProductsQuantities:', prints);
|
|
31
|
+
console.log('minimumPrintOrderQuantity: ', minimumPrintOrderQuantity);
|
|
32
|
+
console.log('minimumOrderQuantity: ', minimumOrderQuantity);
|
|
33
|
+
const minQty = (prints?.length > 0 ? minimumPrintOrderQuantity : minimumOrderQuantity) || minimumOrderQuantity;
|
|
34
|
+
return { _id, name, minimumOrderQuantity: minQty, quantity: getEntitiesQuantity(grouped[_id]) };
|
|
30
35
|
});
|
|
31
36
|
return quantities;
|
|
32
37
|
};
|
package/store/product.js
CHANGED
|
@@ -123,7 +123,7 @@ export const getters = {
|
|
|
123
123
|
.filter(printType => layersPrintTypes.includes(printType._id || printType))
|
|
124
124
|
.map(printType => printType.minQuantity);
|
|
125
125
|
return Math.max(
|
|
126
|
-
product.minimumOrderQuantity,
|
|
126
|
+
layersPrintTypes?.length > 0 ? product.minimumPrintOrderQuantity : product.minimumOrderQuantity,
|
|
127
127
|
...printTypesMinQuantity
|
|
128
128
|
);
|
|
129
129
|
},
|
package/store/products.js
CHANGED
|
@@ -33,6 +33,14 @@ export const getters = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export const actions = {
|
|
36
|
+
async fetchBrands({ commit }, shop) {
|
|
37
|
+
const brands = await api.fetchProductsBrands(shop, { limit: 10 });
|
|
38
|
+
commit('setBrands', brands);
|
|
39
|
+
},
|
|
40
|
+
async fetchTypes({ commit }, shop) {
|
|
41
|
+
const types = await api.fetchProductsTypes(shop, { limit: 10 });
|
|
42
|
+
commit('setTypes', types);
|
|
43
|
+
},
|
|
36
44
|
async fetchProducts({ commit }, { shop, params }) {
|
|
37
45
|
try {
|
|
38
46
|
commit('setLoadError', null);
|