@lancom/shared 0.0.285 → 0.0.286

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.
@@ -160,8 +160,8 @@ const api = {
160
160
  fetchAddressInfo(id, shop) {
161
161
  return _get(`shop/${shop || '-1'}/postcodes/address/${id}`);
162
162
  },
163
- fetchProductPrintTemplates() {
164
- return _get('print-templates');
163
+ fetchProductPrintTemplates(shop) {
164
+ return _get(`shop/${shop || '-1'}/print-templates`);
165
165
  },
166
166
  fetchPrintTypes(shop) {
167
167
  return _get(`shop/${shop}/print-types`);
@@ -64,7 +64,7 @@ export class TextLayer extends Layer {
64
64
 
65
65
  export class ArtLayer extends Layer {
66
66
  url = null;
67
- fileName = 'default';
67
+ fileName = '';
68
68
  editableDetails = true;
69
69
  scaleX = 1;
70
70
  scaleY = 1;
@@ -8,6 +8,9 @@ $mobile_notification_bar_height: 40px !default;
8
8
  // Scrollbar
9
9
  $scrollbar_width: 6px;
10
10
 
11
+ $orange: #e76d00 !default;
12
+ $orange_light: #ff9940 !default;
13
+
11
14
  // Colors
12
15
  $black_high_emphasis: #000000;
13
16
  $black_medium_emphasis: rgba(0, 0, 0, .66);
@@ -96,8 +96,7 @@ export default {
96
96
  type: String
97
97
  },
98
98
  labelText: {
99
- type: String,
100
- default: 'Suburb'
99
+ type: String
101
100
  },
102
101
  placeholder: {
103
102
  type: String,
@@ -131,7 +130,7 @@ export default {
131
130
  computed: {
132
131
  ...mapGetters(['shop', 'MESSAGES']),
133
132
  displayLabelText() {
134
- return this.MESSAGES.POSTCODES_LABEL || this.labelText;
133
+ return this.labelText || this.MESSAGES.POSTCODES_LABEL || 'Suburb';
135
134
  },
136
135
  model: {
137
136
  get() {
@@ -48,7 +48,7 @@ export default {
48
48
  };
49
49
  },
50
50
  computed: {
51
- ...mapGetters(['shop'])
51
+ ...mapGetters(['shop', 'country'])
52
52
  },
53
53
  methods: {
54
54
  select(product) {
@@ -58,7 +58,7 @@ export default {
58
58
  async loadProducts(text) {
59
59
  try {
60
60
  this.loading = true;
61
- this.products = (await api.fetchProducts(this.shop._id, { text })).products;
61
+ this.products = (await api.fetchProducts(this.shop._id, { text, country: this.country?._id })).products;
62
62
  } catch (e) {
63
63
  } finally {
64
64
  this.loading = false;
@@ -121,7 +121,7 @@ export default {
121
121
  const printAreas = getAllPrintAreas(this.product);
122
122
  const groups = new Map();
123
123
  this.editableLayers.forEach(layer => {
124
- const printArea = printAreas.find(pa => pa._id === layer.printArea);
124
+ const printArea = printAreas.find(pa => pa._id === layer.printArea) || { _id: null, name: 'Layers'};
125
125
  if (printArea) {
126
126
  const defaultGroup = { layers: [], printArea };
127
127
  const group = groups.get(printArea._id) || defaultGroup;
@@ -107,13 +107,13 @@ export default {
107
107
  }
108
108
  let quality;
109
109
  switch (true) {
110
- case this.layer.dpi < 100:
110
+ case this.layer.dpi < 75:
111
111
  quality = 'too small';
112
112
  break;
113
- case this.layer.dpi >= 100 && this.layer.dpi < 150:
113
+ case this.layer.dpi >= 75 && this.layer.dpi < 100:
114
114
  quality = 'low quality';
115
115
  break;
116
- case this.layer.dpi >= 150:
116
+ case this.layer.dpi >= 100:
117
117
  quality = 'good quality';
118
118
  break;
119
119
  }
@@ -29,7 +29,9 @@
29
29
  </template>
30
30
  </v-popover>
31
31
  </span>
32
- <span class="lc_regular16 lc_grey1 ml-6">
32
+ <span
33
+ v-if="isPrintPricing"
34
+ class="lc_regular16 lc_grey1 ml-6">
33
35
  +
34
36
  <v-popover
35
37
  ref="popover"
@@ -108,7 +110,8 @@ export default {
108
110
  'product',
109
111
  'productDetailsLoaded',
110
112
  'defaultSimpleProduct',
111
- 'selectedPrintType'
113
+ 'selectedPrintType',
114
+ 'isPrintPricing'
112
115
  ]),
113
116
  ...mapGetters('layers', [
114
117
  'layerThumbnails'
@@ -122,7 +122,7 @@ export default {
122
122
  'editModeSelectedLayer'
123
123
  ]),
124
124
  printAreaLayers() {
125
- return this.editableLayers.filter(l => l.printArea === this.printArea._id);
125
+ return this.editableLayers.filter(l => !this.printArea || l.printArea === this.printArea._id);
126
126
  },
127
127
  deleteButtonPosition() {
128
128
  return this.deleteButtonPos ? {
@@ -230,15 +230,16 @@ export default {
230
230
  this.fabricHelper.scaleWorkspace({ width: size, height: size });
231
231
  },
232
232
  initEventsListeners() {
233
- document.addEventListener('click', this.onDocumentClick);
233
+ document.addEventListener('mousedown', this.onDocumentStartClick);
234
234
  window.addEventListener('resize', this.onResize);
235
235
  },
236
236
  clearEventsListeners() {
237
- document.removeEventListener('click', this.onDocumentClick);
237
+ document.removeEventListener('mousedown', this.onDocumentStartClick);
238
238
  window.removeEventListener('resize', this.onResize);
239
239
  },
240
240
  onDocumentClick({ target }) {
241
241
  // todo: replace by click outside plugin?
242
+ console.log('target: ', target);
242
243
  const isCanvasElement = target.tagName === 'CANVAS';
243
244
  const isIgnoreClick = !!findParentByPredicate(target, element => element.hasAttribute('ignore-document-click'));
244
245
  if (!isCanvasElement && !isIgnoreClick) {
@@ -28,11 +28,9 @@
28
28
  </template>
29
29
 
30
30
  <script>
31
- import { createNamespacedHelpers } from 'vuex';
31
+ import { mapMutations, mapActions, mapGetters } from 'vuex';
32
32
  import api from '@lancom/shared/assets/js/api';
33
33
 
34
- const { mapMutations, mapActions, mapGetters } = createNamespacedHelpers('product');
35
-
36
34
  export default {
37
35
  name: 'EditorLayersTemplates',
38
36
  data() {
@@ -42,16 +40,17 @@ export default {
42
40
  };
43
41
  },
44
42
  computed: {
45
- ...mapGetters(['printArea', 'editableLayers'])
43
+ ...mapGetters(['shop']),
44
+ ...mapGetters('product', ['printArea', 'editableLayers'])
46
45
  },
47
46
  async mounted() {
48
47
  this.loading = true;
49
- this.layerTemplates = await api.fetchProductPrintTemplates();
48
+ this.layerTemplates = await api.fetchProductPrintTemplates(this.shop._id);
50
49
  this.loading = false;
51
50
  },
52
51
  methods: {
53
- ...mapActions(['createLayer']),
54
- ...mapMutations(['updateTemplateLayer', 'setSelectedLayer']),
52
+ ...mapActions('product', ['createLayer']),
53
+ ...mapMutations('product', ['updateTemplateLayer', 'setSelectedLayer']),
55
54
  async applyLayerTemplate(template) {
56
55
  this.loading = true;
57
56
  const printArea = this.printArea;
@@ -14,6 +14,34 @@
14
14
  }
15
15
  }
16
16
  }
17
+ &__tag {
18
+ position: absolute;
19
+ top: 14px;
20
+ right: 14px;
21
+ display: flex;
22
+ flex-direction: column;
23
+ align-items: flex-end;
24
+ z-index: 3;
25
+ &-icon {
26
+ margin-bottom: 4px;
27
+ font-size: 12px;
28
+ color: $orange
29
+ }
30
+ &-item {
31
+ margin-bottom: 2px;
32
+ span {
33
+ display: inline-block;
34
+ padding: 4px 5px;
35
+ background: $orange_light;
36
+ font-weight: 800;
37
+ font-size: 10px;
38
+ line-height: 14px;
39
+ letter-spacing: -0.02em;
40
+ text-transform: uppercase;
41
+ color: $black;
42
+ }
43
+ }
44
+ }
17
45
  &__colors {
18
46
  display: flex;
19
47
  flex-wrap: wrap;
@@ -38,6 +38,23 @@
38
38
  <!-- <div class="ProductListProduct__gender">
39
39
  <span>{{ product.gender }}</span>
40
40
  </div> -->
41
+ <div
42
+ v-if="hasTags"
43
+ class="ProductListProduct__tag">
44
+ <div
45
+ v-for="tag in tags"
46
+ :key="`${tag._id}-${product._id}`"
47
+ class="ProductListProduct__tag-item">
48
+ <span
49
+ :style="{
50
+ 'background-color': tag.backgroundColor,
51
+ 'color': tag.textColor,
52
+ 'font-size': tag.fontSize
53
+ }">
54
+ {{ tag.name }}
55
+ </span>
56
+ </div>
57
+ </div>
41
58
  </a>
42
59
  <div class="ProductListProduct__info">
43
60
  <div class="ProductListProduct__info-item">
@@ -334,7 +334,7 @@
334
334
  }
335
335
  }
336
336
  &__aside {
337
- width: 230px;
337
+ width: 215px;
338
338
  flex-grow: 1;
339
339
  flex-shrink: 0;
340
340
  @media (max-width: $bp-small-max) {
@@ -30,8 +30,8 @@ export default (IS_PRODUCT_PRESET_PRINT_PRICING) => ({
30
30
  await store.dispatch('product/fetchProduct', data);
31
31
  await store.dispatch('product/fetchProductDetails', data);
32
32
 
33
- if (IS_PRODUCT_PRESET_PRINT_PRICING) {
34
- const product = store.getters['product/product'];
33
+ const product = store.getters['product/product'];
34
+ if (IS_PRODUCT_PRESET_PRINT_PRICING && product.printOnly) {
35
35
  const printType = product.printTypes[0];
36
36
  store.commit('product/setSelectedPrintType', printType);
37
37
  store.commit('product/setIsPrintPricing', true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.285",
3
+ "version": "0.0.286",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/product.js CHANGED
@@ -363,6 +363,11 @@ export const mutations = {
363
363
  layer
364
364
  ];
365
365
  Vue.set(state.template, 'layers', layers);
366
+ if (layers.length === 1 && !state.product.printOnly) {
367
+ const printType = state.product.printTypes[0];
368
+ state.selectedPrintType = printType;
369
+ state.isPrintPricing = true;
370
+ }
366
371
  },
367
372
  removeTemplateLayer(state, layer) {
368
373
  const index = state.template.layers.findIndex(({ createdAt }) => createdAt === layer.createdAt);
@@ -370,6 +375,10 @@ export const mutations = {
370
375
  if (state.selectedLayer && state.selectedLayer.createdAt === layer.createdAt) {
371
376
  state.selectedLayer = null;
372
377
  }
378
+ if (state.template.layers.length === 0 && !state.product.printOnly) {
379
+ state.selectedPrintType = null;
380
+ state.isPrintPricing = false;
381
+ }
373
382
  },
374
383
  updateTemplateLayer(state, layer) {
375
384
  const index = state.template.layers.findIndex(({ createdAt, _id }) => createdAt === layer.createdAt || (_id && _id === layer._id));