@lancom/shared 0.0.314 → 0.0.315
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/js/models/print-area.js +19 -13
- package/assets/js/utils/prints.js +4 -3
- package/assets/js/utils/product.js +1 -1
- package/components/checkout/order/order-payment-information/order-payment-information.vue +4 -2
- package/components/common/payment/payment_card/pinpayment/pinpayment.vue +7 -7
- package/components/editor/editor_layers/editor-layers.vue +4 -4
- package/components/editor/editor_print_area_options/editor-print-area-options.vue +15 -3
- package/components/editor/editor_workspace/editor-workspace.vue +21 -3
- package/components/editor/editor_workspace/editor_workspace_side/editor-workspace-side.vue +3 -1
- package/components/product/products_size_selector_color/product_size_selector_color/product-size-selector-color.vue +5 -2
- package/mixins/product-view.js +1 -1
- package/package.json +1 -1
- package/store/product.js +1 -1
|
@@ -13,21 +13,26 @@ const DEFAULT_PRINT_AREA = {
|
|
|
13
13
|
|
|
14
14
|
export const PIXELS_PER_CM = 37.795275591;
|
|
15
15
|
|
|
16
|
-
export const getProductPrintAreas = product => {
|
|
16
|
+
export const getProductPrintAreas = (product, includeSize) => {
|
|
17
17
|
if (!product) {
|
|
18
18
|
return {};
|
|
19
19
|
}
|
|
20
|
-
const getSizesFromAreas = (areas, map, printAreaSide) => (areas || []).reduce((list, { printSize, side, printAreaOffsets, sizes, _id }) => {
|
|
21
|
-
if (_id && printSize) {
|
|
22
|
-
list[_id] = { printSize, side: printAreaSide || side, printAreaOffsets };
|
|
23
|
-
}
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const getSizesFromAreas = (areas, map, printAreaSide, printAreaId) => {
|
|
22
|
+
return (areas || [])
|
|
23
|
+
.reduce((list, { printSize, side, printAreaOffsets, sizes, _id }) => {
|
|
24
|
+
if (_id && printSize) {
|
|
25
|
+
const key = includeSize ? `${printAreaId || _id}_${printSize?._id || printSize}` : _id;
|
|
26
|
+
list[key] = { printSize, side: printAreaSide || side, printAreaOffsets };
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
if (sizes) {
|
|
30
|
+
getSizesFromAreas(sizes, list, printAreaSide || side, printAreaId || _id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return list;
|
|
34
|
+
}, map || {});
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
return getSizesFromAreas(product.printAreas);
|
|
33
38
|
};
|
|
@@ -42,11 +47,12 @@ export const getProductPrintsAreasPrices = (product, printType) => {
|
|
|
42
47
|
return areas;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
|
-
export const getPrintAreaByName = (params, product) => {
|
|
50
|
+
export const getPrintAreaByName = (params, product, includeSize) => {
|
|
46
51
|
const { printArea, editorWidth, editorHeight, printSize, printAreaOffsets } = params;
|
|
47
|
-
const printAreas = getProductPrintAreas(product);
|
|
48
|
-
const pa = printAreas[printArea] || DEFAULT_PRINT_AREA;
|
|
52
|
+
const printAreas = getProductPrintAreas(product, !!includeSize);
|
|
49
53
|
const printSizeId = printSize?._id || printSize;
|
|
54
|
+
const key = includeSize ? `${printArea}_${printSizeId}` : printArea;
|
|
55
|
+
const pa = printAreas[key] || DEFAULT_PRINT_AREA;
|
|
50
56
|
const productPrintArea = product.printAreasOffsets?.find(p => p.printAreas?.includes(printArea) && (!p.printSize || p.printSize === printSizeId));
|
|
51
57
|
const size = productPrintArea?.printAreaSize || (printSize?._id && printSize) || pa.printSize;
|
|
52
58
|
const sideId = productPrintArea?.side || pa.side;
|
|
@@ -39,7 +39,8 @@ export function getPrintsFromLayers(layers, product) {
|
|
|
39
39
|
const prints = new Map();
|
|
40
40
|
(layers || []).forEach(layer => {
|
|
41
41
|
const { printType, printSize, printArea } = layer;
|
|
42
|
-
|
|
42
|
+
const printAreaKey = `${printArea}_${printSize}`;
|
|
43
|
+
if (!prints.has(printAreaKey)) {
|
|
43
44
|
const layerPrintType = product.printTypes.find(({ _id }) => _id === printType);
|
|
44
45
|
const layerPrintArea = product.printAreas.find(({ _id }) => _id === printArea);
|
|
45
46
|
const sizes = layerPrintArea ? getPrintAreaSizes(layerPrintArea) : [];
|
|
@@ -57,13 +58,13 @@ export function getPrintsFromLayers(layers, product) {
|
|
|
57
58
|
printCost,
|
|
58
59
|
layers: [generatePrintLayer(layer)]
|
|
59
60
|
};
|
|
60
|
-
prints.set(
|
|
61
|
+
prints.set(printAreaKey, data);
|
|
61
62
|
layer.printGuid = data.guid;
|
|
62
63
|
} else {
|
|
63
64
|
const print = prints.get(printArea);
|
|
64
65
|
layer.printGuid = print.guid;
|
|
65
66
|
print.layers.push(generatePrintLayer(layer));
|
|
66
|
-
prints.set(
|
|
67
|
+
prints.set(printAreaKey, print);
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
return [...prints.values()];
|
|
@@ -130,11 +130,12 @@ export default {
|
|
|
130
130
|
initedCard() {
|
|
131
131
|
this.loadingCard = false;
|
|
132
132
|
},
|
|
133
|
-
async initOrderData() {
|
|
133
|
+
async initOrderData(paymentStatus) {
|
|
134
134
|
if (!this.orderData) {
|
|
135
135
|
const recaptchaToken = await this.getRecaptcha('create_order');
|
|
136
136
|
await this.createOrder({
|
|
137
137
|
...this.order,
|
|
138
|
+
paymentStatus: paymentStatus || 'abandoned',
|
|
138
139
|
recaptchaToken,
|
|
139
140
|
products: this.entities,
|
|
140
141
|
pricing: this.cartPricing,
|
|
@@ -184,11 +185,12 @@ export default {
|
|
|
184
185
|
try {
|
|
185
186
|
this.creating = true;
|
|
186
187
|
if (!this.orderData) {
|
|
187
|
-
await this.initOrderData();
|
|
188
|
+
await this.initOrderData('pending');
|
|
188
189
|
} else {
|
|
189
190
|
const data = {
|
|
190
191
|
...this.orderData,
|
|
191
192
|
...this.order,
|
|
193
|
+
paymentStatus: 'pending',
|
|
192
194
|
charge: null
|
|
193
195
|
};
|
|
194
196
|
await this.saveOrder(data);
|
|
@@ -174,16 +174,16 @@ export default {
|
|
|
174
174
|
tokenize() {
|
|
175
175
|
this.processing = true;
|
|
176
176
|
return new Promise((resolve, reject) => {
|
|
177
|
-
const
|
|
177
|
+
const address = this.order.shippingAddress || this.order.address;
|
|
178
178
|
this.fields.tokenize(
|
|
179
179
|
{
|
|
180
180
|
publishable_api_key: process.env.PINPAYMENT_PUBLISHABLE_API_KEY,
|
|
181
|
-
address_line1:
|
|
182
|
-
address_line2:
|
|
183
|
-
address_city:
|
|
184
|
-
address_postcode:
|
|
185
|
-
address_state:
|
|
186
|
-
address_country:
|
|
181
|
+
address_line1: address.addressLine1,
|
|
182
|
+
address_line2: address.addressLine2,
|
|
183
|
+
address_city: address.city,
|
|
184
|
+
address_postcode: address.postcode,
|
|
185
|
+
address_state: address.state,
|
|
186
|
+
address_country: address.country
|
|
187
187
|
},
|
|
188
188
|
(err, response) => {
|
|
189
189
|
if (!this.processing) {
|
|
@@ -129,7 +129,7 @@ export default {
|
|
|
129
129
|
const printAreas = getAllPrintAreas(this.product);
|
|
130
130
|
const groups = new Map();
|
|
131
131
|
this.editableLayers.forEach(layer => {
|
|
132
|
-
const printArea = printAreas.find(pa => pa._id === layer.printArea) || { _id: null, name: 'Layers'};
|
|
132
|
+
const printArea = printAreas.find(pa => (pa.parentPrintArea || pa._id) === layer.printArea && pa.printSize._id === layer.printSize) || { _id: null, name: 'Layers'};
|
|
133
133
|
if (printArea) {
|
|
134
134
|
const defaultGroup = { layers: [], printArea };
|
|
135
135
|
const group = groups.get(printArea._id) || defaultGroup;
|
|
@@ -171,9 +171,9 @@ export default {
|
|
|
171
171
|
}
|
|
172
172
|
this.setEditablePrintArea(printArea);
|
|
173
173
|
this.setSelectedPrintArea({
|
|
174
|
-
sideId: printArea
|
|
175
|
-
printArea: printArea
|
|
176
|
-
size: printArea
|
|
174
|
+
sideId: printArea?.side,
|
|
175
|
+
printArea: printArea?._id,
|
|
176
|
+
size: printArea?.printSize
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
},
|
|
@@ -47,6 +47,10 @@ export default {
|
|
|
47
47
|
allowNoPrint: {
|
|
48
48
|
type: Boolean,
|
|
49
49
|
default: false
|
|
50
|
+
},
|
|
51
|
+
layers: {
|
|
52
|
+
type: Array,
|
|
53
|
+
default: () => ([])
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
computed: {
|
|
@@ -57,10 +61,10 @@ export default {
|
|
|
57
61
|
const mainOption = { ...groupItemToOption(printArea), sides: [printArea.side] };
|
|
58
62
|
const suboptions = [
|
|
59
63
|
mainOption,
|
|
60
|
-
...(printArea.sizes || []).map(i => ({ ...groupItemToOption({ ...i, side: printArea.side }), sides: [printArea.side] }))
|
|
64
|
+
...(printArea.sizes || []).map(i => ({ ...groupItemToOption({ ...i, side: printArea.side, parentPrintArea: printArea._id }), sides: [printArea.side] }))
|
|
61
65
|
];
|
|
62
66
|
return {
|
|
63
|
-
...(suboptions.find(s => s.printArea?._id === this.selected) || mainOption),
|
|
67
|
+
...(suboptions.find(s => s.printArea?._id === this.selected || this.hasPrintAreaLayers(s.printArea)) || mainOption),
|
|
64
68
|
suboptions
|
|
65
69
|
};
|
|
66
70
|
});
|
|
@@ -70,12 +74,20 @@ export default {
|
|
|
70
74
|
},
|
|
71
75
|
mounted() {
|
|
72
76
|
if (!this.selected) {
|
|
73
|
-
this.
|
|
77
|
+
const allOptions = this.options.reduce((options, option) => [...options, option, ...(option.suboptions || [])], []);
|
|
78
|
+
const option = allOptions.find(o => this.hasPrintAreaLayers(o.printArea)) || this.options[0];
|
|
79
|
+
this.select(option);
|
|
74
80
|
}
|
|
75
81
|
},
|
|
76
82
|
methods: {
|
|
77
83
|
select(option) {
|
|
78
84
|
this.$emit('select', option);
|
|
85
|
+
},
|
|
86
|
+
hasPrintAreaLayers(printArea) {
|
|
87
|
+
const paId = printArea?.parentPrintArea || printArea?._id;
|
|
88
|
+
const psId = printArea?.printSize?._id;
|
|
89
|
+
const layers = this.layers.filter(l => !paId || (l.printArea === paId && l.printSize === psId));
|
|
90
|
+
return layers.length > 0;
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
93
|
};
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
:product="product"
|
|
101
101
|
:selected="editablePrintArea && editablePrintArea._id"
|
|
102
102
|
:side="editableSide.id"
|
|
103
|
+
:layers="editableLayers"
|
|
103
104
|
@select="selectPrintArea"
|
|
104
105
|
@option-mouseover="toogleBoundBox(true, $event)"
|
|
105
106
|
@option-mouseleave="toogleBoundBox(false, $event)">
|
|
@@ -148,7 +149,8 @@ export default {
|
|
|
148
149
|
'selectedPrintArea',
|
|
149
150
|
'editablePrintArea',
|
|
150
151
|
'editableSide',
|
|
151
|
-
'editableColor'
|
|
152
|
+
'editableColor',
|
|
153
|
+
'editableLayers'
|
|
152
154
|
]),
|
|
153
155
|
isZoomIn() {
|
|
154
156
|
return !!this.zoomSize;
|
|
@@ -188,9 +190,25 @@ export default {
|
|
|
188
190
|
id: side || (this.editableSide.id === 'front' ? 'back' : 'front')
|
|
189
191
|
});
|
|
190
192
|
},
|
|
191
|
-
selectPrintArea(
|
|
193
|
+
selectPrintArea(pa) {
|
|
194
|
+
const { printArea, size } = pa || {};
|
|
195
|
+
const oldPrintArea = this.editablePrintArea;
|
|
196
|
+
// console.log('');
|
|
197
|
+
// console.log('selectPrintArea: ');
|
|
198
|
+
// console.log('oldPrintArea: ', oldPrintArea);
|
|
199
|
+
// console.log('printArea: ', printArea);
|
|
200
|
+
// console.log('this.editableLayers: ', this.editableLayers);
|
|
192
201
|
this.setEditablePrintArea(printArea);
|
|
193
|
-
|
|
202
|
+
const oldPaId = oldPrintArea?.parentPrintArea || oldPrintArea?._id;
|
|
203
|
+
const paId = printArea?.parentPrintArea || printArea?._id;
|
|
204
|
+
if (oldPaId && oldPaId === paId) {
|
|
205
|
+
this.editableLayers.forEach(layer => {
|
|
206
|
+
if (layer.printArea === paId) {
|
|
207
|
+
layer.printSize = printArea.printSize?._id;
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
}
|
|
211
|
+
this.setSelectedPrintArea({ sideId: this.editableSide.id, printArea: printArea?._id, parentPrintArea: printArea?.parentPrintArea, size });
|
|
194
212
|
},
|
|
195
213
|
toogleBoundBox(state, printAreaOption) {
|
|
196
214
|
if (this.$refs.editor) {
|
|
@@ -145,7 +145,9 @@ export default {
|
|
|
145
145
|
return this.editableLayers.filter(l => l.sideId === this.side);
|
|
146
146
|
},
|
|
147
147
|
printAreaLayers() {
|
|
148
|
-
|
|
148
|
+
const paId = this.printArea?.parentPrintArea || this.printArea?._id;
|
|
149
|
+
const layers = this.editableLayers.filter(l => !paId || (l.printArea === paId));
|
|
150
|
+
return layers;
|
|
149
151
|
},
|
|
150
152
|
deleteButtonPosition() {
|
|
151
153
|
return this.deleteButtonPos ? {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
<div v-if="printsPrice > 0">
|
|
23
23
|
<price
|
|
24
24
|
class="lc_semibold17 ProductSizeSelectorColor__price"
|
|
25
|
-
:price="
|
|
26
|
-
:with-gst="
|
|
25
|
+
:price="productPrintsPrice + productPrice"
|
|
26
|
+
:with-gst="false" />
|
|
27
27
|
</div>
|
|
28
28
|
<div>
|
|
29
29
|
<v-popover
|
|
@@ -140,6 +140,9 @@ export default {
|
|
|
140
140
|
const price = (pricing.find(({ min, max }) => (!min || min <= amount) && (!max || max >= amount)) || pricing[0] || {}).price || 0;
|
|
141
141
|
return this.withGst ? tax(price, this.gstTax) : price;
|
|
142
142
|
},
|
|
143
|
+
productPrintsPrice() {
|
|
144
|
+
return this.withGst ? tax(this.printsPrice, this.gstTax) : this.printsPrice;
|
|
145
|
+
},
|
|
143
146
|
disabled() {
|
|
144
147
|
return !this.product.quantityStock || !this.productPrice;
|
|
145
148
|
},
|
package/mixins/product-view.js
CHANGED
|
@@ -129,7 +129,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING) => ({
|
|
|
129
129
|
// printAreaOffsets: printArea?.printAreaOffsets,
|
|
130
130
|
editorWidth: this.editorSize.width,
|
|
131
131
|
editorHeight: this.editorSize.height
|
|
132
|
-
}, this.product);
|
|
132
|
+
}, this.product, true);
|
|
133
133
|
fitLayerToEditorSize(properties, preSetPrint.printTemplate, printArea);
|
|
134
134
|
properties.sideId = printArea?.sideId;
|
|
135
135
|
}
|
package/package.json
CHANGED
package/store/product.js
CHANGED
|
@@ -241,7 +241,7 @@ export const actions = {
|
|
|
241
241
|
sideId: getters.editableSide?.id,
|
|
242
242
|
properties: {
|
|
243
243
|
...(properties || {}),
|
|
244
|
-
printArea: editablePrintArea?._id,
|
|
244
|
+
printArea: editablePrintArea?.parentPrintArea || editablePrintArea?._id,
|
|
245
245
|
printSize: editablePrintArea?.printSize?._id,
|
|
246
246
|
printType: selectedPrintType?._id
|
|
247
247
|
}
|