@lancom/shared 0.0.339 → 0.0.341

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.
@@ -456,6 +456,9 @@ export default {
456
456
  runGrabber(grabber) {
457
457
  return _post(`admin/grabbers/${grabber._id}/run`, grabber);
458
458
  },
459
+ getGrabberSKUVariants(grabber) {
460
+ return _post(`admin/grabbers/${grabber._id}/sku-variants`, grabber);
461
+ },
459
462
  removeGrabber(id) {
460
463
  return _delete(`admin/grabbers/${id}`);
461
464
  },
@@ -1,24 +1,34 @@
1
1
  <template>
2
- <div
3
- class="FileUploader__wrapper"
4
- :class="[error ? 'error' : '', dragging ? 'active' : '']"
5
- @dragenter="dragging=true"
6
- @dragend="dragging=false"
7
- @dragleave="dragging=false"
8
- @drop="dragging=false">
9
- <div class="FileUploader__dropzone">
10
- <slot name="toggle" :uploading="uploading"></slot>
11
- <slot name="progress" :progress="progress"></slot>
2
+ <div>
3
+ <div
4
+ class="FileUploader__wrapper"
5
+ :class="[error ? 'error' : '', dragging ? 'active' : '']"
6
+ @dragenter="dragging=true"
7
+ @dragend="dragging=false"
8
+ @dragleave="dragging=false"
9
+ @drop="dragging=false">
10
+ <div class="FileUploader__dropzone">
11
+ <slot name="toggle" :uploading="uploading"></slot>
12
+ <slot name="progress" :progress="progress"></slot>
13
+ <input
14
+ ref="fileUploaderField"
15
+ class="FileUploader__input"
16
+ type="file"
17
+ :class="{ disabled: disabled || uploading }"
18
+ :multiple="multiple"
19
+ :accept="accept"
20
+ :required="required"
21
+ :disabled="disabled || uploading"
22
+ @change="fileChange" />
23
+ </div>
24
+ </div>
25
+ <div v-if="hasUploadLink">
12
26
  <input
13
- ref="fileUploaderField"
14
- class="FileUploader__input"
15
- type="file"
16
- :class="{ disabled: disabled || uploading }"
17
- :multiple="multiple"
18
- :accept="accept"
19
- :required="required"
20
- :disabled="disabled || uploading"
21
- @change="fileChange" />
27
+ ref="fileLink"
28
+ type="text"
29
+ placeholder="Link"
30
+ class="form-control"
31
+ @change="onPastLink($event)" />
22
32
  </div>
23
33
  </div>
24
34
  </template>
@@ -35,6 +45,7 @@ export default {
35
45
  required: { type: Boolean, default: false },
36
46
  disabled: { type: Boolean, default: false },
37
47
  multiple: { type: Boolean, default: false },
48
+ hasUploadLink: { type: Boolean, default: false },
38
49
  hasConversionErrorModal: { type: Boolean, default: true },
39
50
  showErrorMessage: { type: Boolean, default: true },
40
51
  url: { type: String },
@@ -52,6 +63,25 @@ export default {
52
63
  };
53
64
  },
54
65
  methods: {
66
+ async onPastLink(event) {
67
+ const url = event.target.value?.trim();
68
+ if (!url) return;
69
+
70
+ try {
71
+ const response = await fetch(url);
72
+ const blob = await response.blob();
73
+ const file = new File([blob], 'image.jpg', { type: blob.type });
74
+ await this.readAndUploadFile(file);
75
+ } catch (e) {
76
+ if (this.showErrorMessage) {
77
+ this.$toastr.e('Failed to load image from URL');
78
+ } else {
79
+ this.$emit('onerror', e);
80
+ }
81
+ } finally {
82
+ event.target.value = '';
83
+ }
84
+ },
55
85
  async fileChange(ev) {
56
86
  this.uploading = true;
57
87
  const files = Array.from(ev.target.files);
@@ -146,11 +146,19 @@ export default {
146
146
  if (!selected || !selected.editableDetails) {
147
147
  this.setEditModeSelectedLayer(false);
148
148
  }
149
+ if (selected) {
150
+ this.openSelectedLayerGroup(selected);
151
+ }
149
152
  },
150
153
  editableSide() {
151
154
  this.setEditModeSelectedLayer(false);
152
155
  }
153
156
  },
157
+ mounted() {
158
+ if (this.selectedLayer) {
159
+ this.openSelectedLayerGroup(this.selectedLayer);
160
+ }
161
+ },
154
162
  methods: {
155
163
  ...mapMutations([
156
164
  'setSelectedLayer',
@@ -164,8 +172,14 @@ export default {
164
172
  'setEditablePrintArea'
165
173
  ]),
166
174
  ...mapActions(['increaseLayersUpdatesCount']),
167
- toggleOpenedGroup(printArea) {
168
- this.openedGroup = printArea?._id === this.openedGroup ? null : printArea?._id;
175
+ openSelectedLayerGroup(selected) {
176
+ const group = this.editableLayersGroups.find(g => g.layers?.includes(selected));
177
+ if (group?.printArea) {
178
+ this.toggleOpenedGroup(group?.printArea, true);
179
+ }
180
+ },
181
+ toggleOpenedGroup(printArea, foreOpen) {
182
+ this.openedGroup = (printArea?._id === this.openedGroup && !foreOpen) ? null : printArea?._id;
169
183
  if (printArea) {
170
184
  if (this.editableSide.id !== printArea.side) {
171
185
  this.setEditableSide({ id: printArea.side });
@@ -63,16 +63,19 @@ export default {
63
63
  });
64
64
  const productsOptions = (this.product.printAreas || [])
65
65
  .map(printArea => {
66
- const mainOption = { ...groupItemToOption(printArea), sides: [printArea.side] };
67
66
  const suboptions = [
68
- mainOption,
67
+ { ...groupItemToOption(printArea), sides: [printArea.side] },
69
68
  ...(printArea.sizes || []).map(i => ({ ...groupItemToOption({ ...i, side: printArea.side, parentPrintArea: printArea._id }), sides: [printArea.side] }))
70
- ];
69
+ ]
70
+ .filter(s => !this.product.printAreasDisabled?.includes(s.printArea?._id));
71
+ // console.log('suboptions: ', suboptions);
71
72
  return {
72
- ...(suboptions.find(s => s.printArea?._id === this.selected || this.hasPrintAreaLayers(s.printArea)) || mainOption),
73
+ ...(suboptions.find(s => s.printArea?._id === this.selected || this.hasPrintAreaLayers(s.printArea)) || suboptions[0] || {}),
73
74
  suboptions
74
75
  };
75
- });
76
+ })
77
+ .filter(pa => !!pa.printArea?._id);
78
+ // console.log('productsOptions: ', productsOptions);
76
79
  const options = productsOptions.filter(({ sides }) => sides.includes(this.side));
77
80
  return this.allowNoPrint ? [...options, { label: 'No Print' }] : options;
78
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.339",
3
+ "version": "0.0.341",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {