@lancom/shared 0.0.170 → 0.0.172

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.
@@ -5,7 +5,7 @@
5
5
  <vue-slick-carousel
6
6
  ref="bigCarousel"
7
7
  :key="updateCarouselTime"
8
- :arrows="true"
8
+ :arrows="false"
9
9
  :dots="true"
10
10
  :swipe="false"
11
11
  :speed="800"
@@ -173,11 +173,11 @@ export default {
173
173
  }
174
174
  },
175
175
  mounted() {
176
- const index = this.filteredImages.findIndex(i => i.color === this.editableColor?._id);
177
- if (index > -1) {
178
- this.goToSlide(index, true);
179
- }
180
- console.log('filteredImages: ', this.filteredImages);
176
+ // const index = this.filteredImages.findIndex(i => i.color === this.editableColor?._id);
177
+ // if (index > -1) {
178
+ // this.goToSlide(index, true);
179
+ // }
180
+ // console.log('filteredImages: ', this.filteredImages);
181
181
  },
182
182
  methods: {
183
183
  ...mapActions('product', ['selectColor']),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.170",
3
+ "version": "0.0.172",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/product.js CHANGED
@@ -11,6 +11,7 @@ import { sortByName } from '../assets/js/utils/filters';
11
11
 
12
12
  export const state = () => ({
13
13
  calculatingPrice: false,
14
+ images: [],
14
15
  priceIncludeGST: false,
15
16
  product: null,
16
17
  preSetPrint: null,
@@ -119,15 +120,7 @@ export const getters = {
119
120
  ...printTypesMinQuantity
120
121
  );
121
122
  },
122
- images: ({ product }) => {
123
- const imagesGroups = new Map();
124
- (product.images || [])
125
- .filter(i => isValidImageTypes(i, ['front', 'back', 'model']))
126
- .forEach(i => {
127
- imagesGroups.set(i.color, [...(imagesGroups.get(i.color) || []), i]);
128
- });
129
- return [...imagesGroups.values()].reduce((images, group) => [...images, ...group], []);
130
- },
123
+ images: ({ images }) => images,
131
124
  editableSide: ({ editableSide }) => editableSide,
132
125
  priceIncludeGST: ({ priceIncludeGST }) => priceIncludeGST,
133
126
  hasUnprintedPrice: ({ product }) => product.minUnprintedPrice || product.maxUnprintedPrice
@@ -164,6 +157,19 @@ export const actions = {
164
157
  state.availableColors.find(c => c._id === catalogFrontColorId) ||
165
158
  state.availableColors[0];
166
159
  commit('setEditableColor', editableColor);
160
+
161
+ let images = editableColor ? [
162
+ ...(state.product.images || []).filter(image => image.color === editableColor._id),
163
+ ...(state.product.images || []).filter(image => image.color !== editableColor._id)
164
+ ] : state.product.images;
165
+ const imagesGroups = new Map();
166
+ images
167
+ .filter(i => isValidImageTypes(i, ['front', 'back', 'model']))
168
+ .forEach(i => {
169
+ imagesGroups.set(i.color, [...(imagesGroups.get(i.color) || []), i]);
170
+ });
171
+ images = [...imagesGroups.values()].reduce((images, group) => [...images, ...group], []);
172
+ commit('setImages', images);
167
173
  },
168
174
  async fetchPrintTypes({ commit }, { shop }) {
169
175
  const response = await api.fetchPrintTypes(shop);
@@ -224,7 +230,7 @@ export const actions = {
224
230
  commit('addTemplateColor', color);
225
231
  }
226
232
  const lastSelectedColorId = colorSelected ? color : getters.templateColors[0];
227
- if (lastSelectedColorId) {
233
+ if (lastSelectedColorId && getters.editableColor?._id !== lastSelectedColorId) {
228
234
  commit('setEditableColor', getters.availableColors.find(({ _id }) => lastSelectedColorId === _id));
229
235
  }
230
236
  }
@@ -242,12 +248,8 @@ export const mutations = {
242
248
  },
243
249
  setProductDetails(state, simpleProducts) {
244
250
  const { preSetPrint } = state;
245
- console.log('');
246
- console.log('setProductDetails: ');
247
- console.log('simpleProducts1: ', simpleProducts);
248
251
  simpleProducts = simpleProducts.filter(sp => !preSetPrint || (preSetPrint.colors || []).includes(sp.color._id) )
249
252
  state.productDetails = { simpleProducts };
250
- console.log('simpleProducts2: ', simpleProducts);
251
253
  const availableSizes = [];
252
254
  const sizesPerColor = simpleProducts.reduce((map, { color, size }) => {
253
255
  if (!map[color.alias]) {
@@ -410,6 +412,9 @@ export const mutations = {
410
412
  setEditableSide(state, side) {
411
413
  state.editableSide = side;
412
414
  },
415
+ setImages(state, images) {
416
+ state.images = images;
417
+ },
413
418
  setCalculatingPrice(state, calculatingPrice) {
414
419
  state.calculatingPrice = calculatingPrice;
415
420
  }