@lancom/shared 0.0.331 → 0.0.332

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.
@@ -55,7 +55,12 @@ export default {
55
55
  },
56
56
  computed: {
57
57
  options() {
58
- const groupItemToOption = printArea => ({ printArea, label: printArea.name, size: printArea.printSize.alias });
58
+ const groupItemToOption = printArea => ({
59
+ printArea,
60
+ label: printArea.name,
61
+ size: printArea.printSize.alias,
62
+ sizeLabel: printArea.printSize.name
63
+ });
59
64
  const productsOptions = (this.product.printAreas || [])
60
65
  .map(printArea => {
61
66
  const mainOption = { ...groupItemToOption(printArea), sides: [printArea.side] };
@@ -8,7 +8,7 @@
8
8
  }
9
9
  &__content {
10
10
  text-align: center;
11
- padding: 8px 0;
11
+ padding: 8px 8px 8px 0;
12
12
  display: flex;
13
13
  align-items: center;
14
14
  &:hover {
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  <div class="EditorPrintAreaOption__info">
19
19
  <div class="lc_caption">
20
- {{ option.label }}
20
+ {{ option.label }}. {{ option.sizeLabel }}
21
21
  </div>
22
22
  <div class="lc_regular10">
23
23
  <price
@@ -46,8 +46,10 @@
46
46
  [productType]: true
47
47
  }">
48
48
  </div>
49
- <div class="lc_caption">
50
- {{ suboption.label }}
49
+ <div>
50
+ <div class="lc_caption">
51
+ {{ suboption.label }}. {{ suboption.sizeLabel }}
52
+ </div>
51
53
  </div>
52
54
  </div>
53
55
  </div>
@@ -19,7 +19,7 @@ const COUNTRIES_SIZE_SYSTEMS = {
19
19
  GB: 'UK'
20
20
  };
21
21
 
22
- async function googleShoppingFeed(axios, config, availableStores, country, endSlug = '') {
22
+ async function googleShoppingFeed(axios, config, availableStores, country, isEditor) {
23
23
  const { data } = await axios.get(`${config.LOCAL_API_URL}/feed/products?host=${config.HOST_NAME}&country=${country || ''}`);
24
24
  const spliceFirstImage = images => (images || []).splice(0, 1)[0];
25
25
  const getImages = images => (images || []).length > 0 ? images : null;
@@ -56,7 +56,8 @@ async function googleShoppingFeed(axios, config, availableStores, country, endSl
56
56
  const description = `${product.description || product.fabricInfoShort || product.name || ''}`
57
57
  .replace(/&nbsp;/g, ' ')
58
58
  .replace(/&middot;/, '·');
59
- let link = `https://${config.HOST_NAME}/${product.brand.alias}/${product.productType.alias}/${product.alias}${endSlug || ''}?color=${sp.color.alias}`;
59
+
60
+ let link = `https://${config.HOST_NAME}${generateProductLink(product, sp.color, isEditor)}`;
60
61
  if (sp.multipackQty) {
61
62
  link = `${link}&multipack=${sp.SKU}`
62
63
  }
@@ -180,6 +181,34 @@ async function googleShoppingFeed(axios, config, availableStores, country, endSl
180
181
  }
181
182
  }
182
183
 
184
+ function generateCategoryPath(cat) {
185
+ let category = cat;
186
+ const categories = [];
187
+ while (category) {
188
+ categories.unshift(category.alias);
189
+ category = category.parent;
190
+ }
191
+ let baseLink = '';
192
+ if (categories.length) {
193
+ baseLink = `${categories.join('/')}`;
194
+ }
195
+ return baseLink;
196
+ }
197
+
198
+ function generateProductLink(product, color, toEditor) {
199
+ const baseLink = `/${product.brand?.alias}/${product.productType?.alias}/${product.alias}`;
200
+ let link = toEditor ? `${baseLink}/editor` : baseLink;
201
+ if (product.useTaxonomyUrl) {
202
+ const categoryPath = generateCategoryPath(product.category);
203
+ if (categoryPath) {
204
+ const categoryBaseLink = `/c/${categoryPath}/${product.alias}/${product.SKU.toLowerCase()}`;
205
+ link = toEditor ? `${categoryBaseLink}.html` : `${categoryBaseLink}/info.html`;
206
+ }
207
+ }
208
+ return `${link}${color ? `?color=${color.alias || color}` : ''}`;
209
+ }
210
+
211
+
183
212
  module.exports = {
184
213
  googleShoppingFeed,
185
214
  googleLocalShoppingFeed
@@ -63,6 +63,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
63
63
  }
64
64
 
65
65
  return {
66
+ isEditor,
66
67
  pageItem,
67
68
  breadcrumbs: []
68
69
  };
@@ -80,7 +81,7 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING, isEditor = false) => ({
80
81
  return this.mainProductImageSrc;
81
82
  },
82
83
  pageItemCanonical() {
83
- return generateProductLink(this.product);
84
+ return generateProductLink(this.product, null, this.isEditor);
84
85
  },
85
86
  hasImages() {
86
87
  return this.images.length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.331",
3
+ "version": "0.0.332",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {