@lancom/shared 0.0.410 → 0.0.412

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.
@@ -3,6 +3,12 @@ import { _get, _post, _delete, _put } from './helpers';
3
3
  import { sortSizes } from './../utils/sizes';
4
4
  import { sortByName } from './../utils/filters';
5
5
 
6
+ const CACHE = {
7
+ PRINT_AREAS: 'print-areas',
8
+ PACKAGES: 'packages'
9
+ };
10
+ const promiseCache = new Map();
11
+
6
12
  export default {
7
13
  updateInventoryFromLink(link, warehouse) {
8
14
  const url = `admin/products/inventory/link${warehouse ? `?warehouse=${warehouse}` : ''}`;
@@ -212,8 +218,13 @@ export default {
212
218
  removeCategory(id) {
213
219
  return _delete(`admin/categories/${id}`);
214
220
  },
221
+ dropPackagesCache() {
222
+ promiseCache.delete(CACHE.PACKAGES);
223
+ },
215
224
  fetchPackages() {
216
- return _get('admin/packages');
225
+ const promise = promiseCache.get(CACHE.PACKAGES) || _get('admin/packages');
226
+ promiseCache.set(CACHE.PACKAGES, promise);
227
+ return promise;
217
228
  },
218
229
  fetchPackageById(id) {
219
230
  return _get(`admin/packages/${id}`);
@@ -657,8 +668,16 @@ export default {
657
668
  removePrintType(id) {
658
669
  return _delete(`admin/print-types/${id}`);
659
670
  },
660
- fetchPrintAreas() {
661
- return _get('admin/print-areas');
671
+ dropPrintAreasCache() {
672
+ promiseCache.delete(CACHE.PRINT_AREAS);
673
+ },
674
+ fetchPrintAreas(params) {
675
+ if (params) {
676
+ return _get('admin/print-areas', params);
677
+ }
678
+ const promise = promiseCache.get(CACHE.PRINT_AREAS) || _get('admin/print-areas');
679
+ promiseCache.set(CACHE.PRINT_AREAS, promise);
680
+ return promise;
662
681
  },
663
682
  fetchPrintAreaById(id) {
664
683
  return _get(`admin/print-areas/${id}`);
@@ -669,8 +688,8 @@ export default {
669
688
  removePrintArea(id) {
670
689
  return _delete(`admin/print-areas/${id}`);
671
690
  },
672
- fetchPrintSizes() {
673
- return _get('admin/print-sizes');
691
+ fetchPrintSizes(params) {
692
+ return _get('admin/print-sizes', params);
674
693
  },
675
694
  fetchPrintSizeById(id) {
676
695
  return _get(`admin/print-sizes/${id}`);
@@ -177,7 +177,9 @@ export default {
177
177
  if (this.suburb) {
178
178
  const option = this.createOptionFromSuburb(this.suburb);
179
179
  this.selected = option;
180
- await this.handleSearch(this.selected.value.trim())
180
+ if (this.selected.value) {
181
+ await this.handleSearch(this.selected.value.trim());
182
+ }
181
183
  }
182
184
  },
183
185
  methods: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.410",
3
+ "version": "0.0.412",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {