@esolve/ng-esolve-connect 0.27.4 → 0.27.6

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.
@@ -168,8 +168,14 @@ class EsolveSessionService {
168
168
  if (this.currentSession.valid) {
169
169
  return;
170
170
  }
171
- const stored_session_json = this.cookieService.get(this.storage_key);
172
- const stored_session = (stored_session_json ? JSON.parse(stored_session_json) : null);
171
+ let json_data = this.cookieService.get(this.storage_key);
172
+ if (json_data === '' && localStorage) {
173
+ let local_store_data = localStorage.getItem(this.storage_key);
174
+ if (local_store_data) {
175
+ json_data = local_store_data;
176
+ }
177
+ }
178
+ const stored_session = (json_data ? JSON.parse(json_data) : null);
173
179
  if (!stored_session) {
174
180
  invalidSessionCallback();
175
181
  return;
@@ -188,7 +194,11 @@ class EsolveSessionService {
188
194
  handleSession(user_id, location_id, key, expiry_time, expires, expirationCallback) {
189
195
  const expiration_date = new Date(expiry_time * 1000);
190
196
  const session = new EsolveSession(user_id, location_id, key, expiration_date);
191
- this.cookieService.set(this.storage_key, JSON.stringify(session), expiration_date, '/');
197
+ const json_data = JSON.stringify(session);
198
+ this.cookieService.set(this.storage_key, json_data, expiration_date, '/');
199
+ if (localStorage) {
200
+ localStorage.setItem(this.storage_key, json_data);
201
+ }
192
202
  this._session.next(session);
193
203
  this.startTimer(expirationCallback, expires * 1000);
194
204
  }
@@ -200,7 +210,11 @@ class EsolveSessionService {
200
210
  if (typeof location_id !== 'undefined') {
201
211
  current_session.updateLocation(location_id);
202
212
  }
203
- this.cookieService.set(this.storage_key, JSON.stringify(current_session), current_session.expiration_date, '/');
213
+ const json_data = JSON.stringify(current_session);
214
+ this.cookieService.set(this.storage_key, json_data, current_session.expiration_date, '/');
215
+ if (localStorage) {
216
+ localStorage.setItem(this.storage_key, json_data);
217
+ }
204
218
  this._session.next(current_session);
205
219
  if (typeof callback === 'function') {
206
220
  callback();
@@ -2680,8 +2694,15 @@ class EsolveCouponsService {
2680
2694
  this.deleteCoupons();
2681
2695
  }
2682
2696
  retrieveCache() {
2683
- if (this.cookieService.check(this.storage_key)) {
2684
- const coupons_json = this.cookieService.get(this.storage_key);
2697
+ if (this.cookieService.check(this.storage_key) ||
2698
+ localStorage.getItem(this.storage_key)) {
2699
+ let coupons_json = this.cookieService.get(this.storage_key);
2700
+ if (coupons_json === '' && localStorage) {
2701
+ let local_store_data = localStorage.getItem(this.storage_key);
2702
+ if (local_store_data) {
2703
+ coupons_json = local_store_data;
2704
+ }
2705
+ }
2685
2706
  try {
2686
2707
  return this.jsonDecodeMap(coupons_json);
2687
2708
  }
@@ -2695,6 +2716,9 @@ class EsolveCouponsService {
2695
2716
  if (this.coupons_cache.size > 0) {
2696
2717
  const coupons_json = this.jsonEncodeMap(this.coupons_cache);
2697
2718
  this.cookieService.set(this.storage_key, coupons_json, undefined, '/');
2719
+ if (localStorage) {
2720
+ localStorage.setItem(this.storage_key, coupons_json);
2721
+ }
2698
2722
  }
2699
2723
  else {
2700
2724
  this.deleteCoupons();
@@ -2703,6 +2727,9 @@ class EsolveCouponsService {
2703
2727
  deleteCoupons() {
2704
2728
  this.coupons_cache.clear();
2705
2729
  this.cookieService.delete(this.storage_key, '/');
2730
+ if (localStorage) {
2731
+ localStorage.removeItem(this.storage_key);
2732
+ }
2706
2733
  }
2707
2734
  addCoupon(id, key) {
2708
2735
  if (!this.coupons_cache.has(id)) {
@@ -3835,7 +3862,7 @@ class EsolveStockTransactionHistory {
3835
3862
 
3836
3863
  class EsolveStockItemBase {
3837
3864
  constructor(record = {}) {
3838
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
3865
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
3839
3866
  /**
3840
3867
  * eSolve Generated ID
3841
3868
  */
@@ -3960,6 +3987,10 @@ class EsolveStockItemBase {
3960
3987
  * Image filename
3961
3988
  */
3962
3989
  this.image_name = '';
3990
+ /**
3991
+ * Image Last modified
3992
+ */
3993
+ this.image_last_modified = '';
3963
3994
  let seo_title = '';
3964
3995
  let seo_keywords = '';
3965
3996
  let base_price = 0;
@@ -3974,30 +4005,31 @@ class EsolveStockItemBase {
3974
4005
  this.description = (_e = record.description) !== null && _e !== void 0 ? _e : '';
3975
4006
  this.extended_description = (_f = record.extended_description) !== null && _f !== void 0 ? _f : '';
3976
4007
  this.image_name = (_g = record.image_name) !== null && _g !== void 0 ? _g : '';
3977
- this.category_id = (_h = record.category_id) !== null && _h !== void 0 ? _h : '';
3978
- this.subcategory_id = +((_j = record.subcategory_id) !== null && _j !== void 0 ? _j : 0);
3979
- this.manufacturers_id = +((_k = record.manufacturers_id) !== null && _k !== void 0 ? _k : 0);
3980
- this.ranges_id = +((_l = record.ranges_id) !== null && _l !== void 0 ? _l : 0);
3981
- this.delivery_category = (_m = record.delivery_category) !== null && _m !== void 0 ? _m : 'regular_item';
3982
- this.must_collect = !!+((_o = record.must_collect) !== null && _o !== void 0 ? _o : false);
3983
- this.requires_assembly = !!+((_p = record.requires_assembly) !== null && _p !== void 0 ? _p : false);
3984
- this.active = !!+((_q = record.is_active) !== null && _q !== void 0 ? _q : false);
3985
- this.featured = !!+((_r = record.is_featured) !== null && _r !== void 0 ? _r : false);
3986
- this.allow_quotes = ((_s = record.allow_quotes) !== null && _s !== void 0 ? _s : true);
3987
- this.allow_orders = ((_t = record.allow_orders) !== null && _t !== void 0 ? _t : true);
3988
- this.amount_in_stock = +((_u = record.onhand) !== null && _u !== void 0 ? _u : 0);
3989
- this.total_recipe_items = +((_v = record.total_recipe_items) !== null && _v !== void 0 ? _v : 0);
3990
- this.height = +((_w = record.height) !== null && _w !== void 0 ? _w : 0);
3991
- this.width = +((_x = record.width) !== null && _x !== void 0 ? _x : 0);
3992
- this.length = +((_y = record.length) !== null && _y !== void 0 ? _y : 0);
3993
- this.weight = +((_z = record.weight) !== null && _z !== void 0 ? _z : 0);
4008
+ this.image_last_modified = (_h = record.image_last_modified) !== null && _h !== void 0 ? _h : '';
4009
+ this.category_id = (_j = record.category_id) !== null && _j !== void 0 ? _j : '';
4010
+ this.subcategory_id = +((_k = record.subcategory_id) !== null && _k !== void 0 ? _k : 0);
4011
+ this.manufacturers_id = +((_l = record.manufacturers_id) !== null && _l !== void 0 ? _l : 0);
4012
+ this.ranges_id = +((_m = record.ranges_id) !== null && _m !== void 0 ? _m : 0);
4013
+ this.delivery_category = (_o = record.delivery_category) !== null && _o !== void 0 ? _o : 'regular_item';
4014
+ this.must_collect = !!+((_p = record.must_collect) !== null && _p !== void 0 ? _p : false);
4015
+ this.requires_assembly = !!+((_q = record.requires_assembly) !== null && _q !== void 0 ? _q : false);
4016
+ this.active = !!+((_r = record.is_active) !== null && _r !== void 0 ? _r : false);
4017
+ this.featured = !!+((_s = record.is_featured) !== null && _s !== void 0 ? _s : false);
4018
+ this.allow_quotes = ((_t = record.allow_quotes) !== null && _t !== void 0 ? _t : true);
4019
+ this.allow_orders = ((_u = record.allow_orders) !== null && _u !== void 0 ? _u : true);
4020
+ this.amount_in_stock = +((_v = record.onhand) !== null && _v !== void 0 ? _v : 0);
4021
+ this.total_recipe_items = +((_w = record.total_recipe_items) !== null && _w !== void 0 ? _w : 0);
4022
+ this.height = +((_x = record.height) !== null && _x !== void 0 ? _x : 0);
4023
+ this.width = +((_y = record.width) !== null && _y !== void 0 ? _y : 0);
4024
+ this.length = +((_z = record.length) !== null && _z !== void 0 ? _z : 0);
4025
+ this.weight = +((_0 = record.weight) !== null && _0 !== void 0 ? _0 : 0);
3994
4026
  if (record.unit_of_measure) {
3995
4027
  this.unit_of_measure = record.unit_of_measure;
3996
4028
  }
3997
- base_price = +((_0 = record.regular_sellprice) !== null && _0 !== void 0 ? _0 : 0);
3998
- base_price_with_tax = +((_1 = record.regular_sellprice_inclusive) !== null && _1 !== void 0 ? _1 : 0);
3999
- sell_price = +((_2 = record.sellprice) !== null && _2 !== void 0 ? _2 : 0);
4000
- sell_price_with_tax = +((_3 = record.sellprice_inclusive) !== null && _3 !== void 0 ? _3 : 0);
4029
+ base_price = +((_1 = record.regular_sellprice) !== null && _1 !== void 0 ? _1 : 0);
4030
+ base_price_with_tax = +((_2 = record.regular_sellprice_inclusive) !== null && _2 !== void 0 ? _2 : 0);
4031
+ sell_price = +((_3 = record.sellprice) !== null && _3 !== void 0 ? _3 : 0);
4032
+ sell_price_with_tax = +((_4 = record.sellprice_inclusive) !== null && _4 !== void 0 ? _4 : 0);
4001
4033
  if ((record.tags) && (record.tags.length > 0)) {
4002
4034
  for (const tag of record.tags) {
4003
4035
  this.tags.push(new EsolveTag(tag));
@@ -4037,12 +4069,12 @@ class EsolveStockItemBase {
4037
4069
  this.custom_fields = record.custom_fields;
4038
4070
  }
4039
4071
  if ((record.total_order_qty) || ((record.total_quote_qty))) {
4040
- const total_order_qty = +((_4 = record.total_order_qty) !== null && _4 !== void 0 ? _4 : 0);
4041
- const total_quote_qty = +((_5 = record.total_quote_qty) !== null && _5 !== void 0 ? _5 : 0);
4072
+ const total_order_qty = +((_5 = record.total_order_qty) !== null && _5 !== void 0 ? _5 : 0);
4073
+ const total_quote_qty = +((_6 = record.total_quote_qty) !== null && _6 !== void 0 ? _6 : 0);
4042
4074
  this.history = new EsolveStockTransactionHistory(total_order_qty, total_quote_qty);
4043
4075
  }
4044
- seo_title = (_6 = record.seo_page_title) !== null && _6 !== void 0 ? _6 : '';
4045
- seo_keywords = (_7 = record.seo_keywords) !== null && _7 !== void 0 ? _7 : '';
4076
+ seo_title = (_7 = record.seo_page_title) !== null && _7 !== void 0 ? _7 : '';
4077
+ seo_keywords = (_8 = record.seo_keywords) !== null && _8 !== void 0 ? _8 : '';
4046
4078
  }
4047
4079
  this.price = new EsolveStockPrice(base_price, base_price_with_tax, sell_price, sell_price_with_tax, record.vat_rate, record.vat_item);
4048
4080
  if (seo_title.trim() === '') {
@@ -4085,7 +4117,11 @@ class EsolveStockItemBase {
4085
4117
  }
4086
4118
  getImagePath(image_size) {
4087
4119
  if (this.image_name !== '') {
4088
- return `/images/stock/${image_size}/${this.image_name}`;
4120
+ let param = '';
4121
+ if (this.image_last_modified !== '') {
4122
+ param = `?t=${this.image_last_modified}`;
4123
+ }
4124
+ return `/images/stock/${image_size}/${this.image_name}${param}`;
4089
4125
  }
4090
4126
  return '';
4091
4127
  }
@@ -4177,8 +4213,9 @@ class EsolveMediaStockItem extends EsolveStockItemBase {
4177
4213
  }
4178
4214
 
4179
4215
  class EsolveStockImage {
4180
- constructor(image_name) {
4216
+ constructor(image_name, last_modified = '') {
4181
4217
  this.image_name = image_name;
4218
+ this.last_modified = last_modified;
4182
4219
  if (this.image_name === 'no_image.jpg') {
4183
4220
  this.image_name = '';
4184
4221
  }
@@ -4215,7 +4252,11 @@ class EsolveStockImage {
4215
4252
  }
4216
4253
  getImagePath(image_size) {
4217
4254
  if (this.image_name !== '') {
4218
- return `/images/stock/${image_size}/${this.image_name}`;
4255
+ let param = '';
4256
+ if (this.last_modified !== '') {
4257
+ param = `?t=${this.last_modified}`;
4258
+ }
4259
+ return `/images/stock/${image_size}/${this.image_name}${param}`;
4219
4260
  }
4220
4261
  return '';
4221
4262
  }
@@ -4245,10 +4286,10 @@ class EsolveAdditionalStockImage {
4245
4286
 
4246
4287
  class EsolveStockImageCollection {
4247
4288
  constructor(record) {
4248
- var _a;
4289
+ var _a, _b;
4249
4290
  this.alt_images = [];
4250
4291
  this.additional_images = [];
4251
- this.default_image = new EsolveStockImage((_a = record === null || record === void 0 ? void 0 : record.default_image) !== null && _a !== void 0 ? _a : '');
4292
+ this.default_image = new EsolveStockImage((_a = record === null || record === void 0 ? void 0 : record.default_image) !== null && _a !== void 0 ? _a : '', (_b = record === null || record === void 0 ? void 0 : record.default_image_last_modified) !== null && _b !== void 0 ? _b : '');
4252
4293
  if (!record) {
4253
4294
  return;
4254
4295
  }