ng-easycommerce 0.0.653 → 0.0.655-beta.1

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.
Files changed (30) hide show
  1. package/README.md +6 -0
  2. package/bundles/ng-easycommerce.umd.js +96 -30
  3. package/bundles/ng-easycommerce.umd.js.map +1 -1
  4. package/bundles/ng-easycommerce.umd.min.js +1 -1
  5. package/bundles/ng-easycommerce.umd.min.js.map +1 -1
  6. package/esm2015/lib/core.consts.js +6 -1
  7. package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +5 -4
  8. package/esm2015/lib/ec-component/checkout-ec/dataform-ec/dataform-ec.component.js +10 -4
  9. package/esm2015/lib/ec-component/product-detail-ec/product-detail-ec.component.js +27 -2
  10. package/esm2015/lib/ec-component/product-ec/product-ec.component.js +1 -2
  11. package/esm2015/lib/ec-component/sidebar-ec/sidebar-ec.component.js +5 -4
  12. package/esm2015/lib/ec-component/widgets-ec/paypal-express-ec/paypal-express-ec.component.js +1 -3
  13. package/esm2015/lib/services/cart.service.js +27 -12
  14. package/esm5/lib/core.consts.js +6 -1
  15. package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +5 -4
  16. package/esm5/lib/ec-component/checkout-ec/dataform-ec/dataform-ec.component.js +10 -4
  17. package/esm5/lib/ec-component/product-detail-ec/product-detail-ec.component.js +45 -2
  18. package/esm5/lib/ec-component/product-ec/product-ec.component.js +1 -2
  19. package/esm5/lib/ec-component/sidebar-ec/sidebar-ec.component.js +5 -4
  20. package/esm5/lib/ec-component/widgets-ec/paypal-express-ec/paypal-express-ec.component.js +1 -3
  21. package/esm5/lib/services/cart.service.js +27 -12
  22. package/fesm2015/ng-easycommerce.js +73 -25
  23. package/fesm2015/ng-easycommerce.js.map +1 -1
  24. package/fesm5/ng-easycommerce.js +97 -31
  25. package/fesm5/ng-easycommerce.js.map +1 -1
  26. package/lib/core.consts.d.ts +5 -0
  27. package/lib/ec-component/product-detail-ec/product-detail-ec.component.d.ts +2 -0
  28. package/lib/services/cart.service.d.ts +2 -2
  29. package/ng-easycommerce.metadata.json +1 -1
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ # version 0.0.655-beta.1
2
+ - Soporte para agregar, editar y borrar notas en ítems del carrito:
3
+ - `product-detail-ec`: prellenar textarea con nota existente al volver a la ficha.
4
+ - `cart-ec`: mantener nota al actualizar cantidades.
5
+ # version 0.0.654
6
+ - funcion para excluir paises en el formulario en el proceso del checkout
1
7
  # version 0.0.653
2
8
  - fix: `ecCurrencySymbol` pure:false
3
9
  - **Moneda (currency):** inicializar la moneda activa a partir de `baseCurrency` del canal, cargando siempre `/shop-api/currencies` aunque `applyCurrencyExchange` sea `false`.
@@ -499,6 +499,11 @@
499
499
  * @example ['AR','ES','GB']
500
500
  */
501
501
  this.countries = [];
502
+ /**
503
+ * @description contiene un arreglo de string cuyo contenido son los codigos de los paises a excluir.
504
+ * @example ['GB']
505
+ */
506
+ this.excludedCountries = [];
502
507
  /**
503
508
  *
504
509
  * @param countries debe contener los codigos de los paises que se quiere mostrar
@@ -4744,12 +4749,22 @@
4744
4749
  _this.updateLocalCart();
4745
4750
  _this.requestInProcess.next(false);
4746
4751
  };
4747
- this.updateCartItemQuantity = function (variant_id, quantity) {
4748
- var newQuantity = _this.items.find(function (item) { return item.variant_id == variant_id; }).quantity = quantity;
4752
+ this.updateCartItemQuantity = function (variant_id, quantity, comments) {
4753
+ var normalizedComments = comments !== undefined ? ((comments !== null && comments !== void 0 ? comments : '')).trim() : undefined;
4754
+ var newItems = _this.items.map(function (it) {
4755
+ if (it.variant_id !== variant_id)
4756
+ return it;
4757
+ var updated = __assign$a(__assign$a({}, it), { quantity: Number(quantity) });
4758
+ if (normalizedComments !== undefined) {
4759
+ updated.comments = normalizedComments;
4760
+ }
4761
+ return updated;
4762
+ });
4763
+ _this.items = newItems;
4749
4764
  _this.cartItemsSubject.next(_this.items);
4750
4765
  _this.requestInProcess.next(false);
4751
4766
  _this.updateLocalCart();
4752
- _this.toastrService.show('product-updated', { quantity: newQuantity });
4767
+ _this.toastrService.show('product-updated', { quantity: quantity });
4753
4768
  };
4754
4769
  this.appendToCart = function (cart) {
4755
4770
  _this.updateCartObj(cart);
@@ -4771,11 +4786,11 @@
4771
4786
  // this.googleAnalytics.removeFromCart(product);
4772
4787
  _this.analyticsService.callEvent('remove_from_cart', __assign$a(__assign$a({}, product), { currency: _this.consts.currency.code }));
4773
4788
  };
4774
- this.addIfAllreadyExists = function (product, variant_id, quantityAdd) {
4789
+ this.addIfAllreadyExists = function (product, variant_id, quantityAdd, comments) {
4775
4790
  if (quantityAdd === void 0) { quantityAdd = 1; }
4776
4791
  return _this.items.find(function (item, index) {
4777
4792
  if (item.product.id == product.id && item.variant_id == variant_id) {
4778
- _this.updateItemQuantity(item, _this.findItem(product.id).quantity + quantityAdd);
4793
+ _this.updateItemQuantity(item, _this.findItem(product.id).quantity + quantityAdd, comments);
4779
4794
  return true;
4780
4795
  }
4781
4796
  return false;
@@ -4829,7 +4844,7 @@
4829
4844
  return;
4830
4845
  }
4831
4846
  _this.requestInProcess.next(true);
4832
- var added = _this.addIfAllreadyExists(product, variant_id, quantity);
4847
+ var added = _this.addIfAllreadyExists(product, variant_id, quantity, comments);
4833
4848
  if (!added) {
4834
4849
  var payload = {
4835
4850
  productCode: product.id,
@@ -4869,7 +4884,7 @@
4869
4884
  !added && _this.connection.post(_this.addItemApi(), { productCode: product.id, quantity: quantity, variantCode: variant_id, id: id || '', order_item_id: order_item_id || '', lot_quantity: lot_quantity || '', unit_price: unit_price || '', unit_total: unit_total || '', ajustement_total: ajustement_total || '', total_lot: total_lot || '', lot_status: lot_status || '', date_request: date_request || '', notes: notes || '', shipping_address_id: shipping_address_id || '', shipping_address_name: shipping_address_name || '', action: action || 'newlot' })
4870
4885
  .subscribe(function (res) { return _this.appendToCart(res); }, function (err) { return _this.handleError(err); });
4871
4886
  };
4872
- this.addToCartPromise = function (product, quantity, variant_id) { return __awaiter$5(_this, void 0, void 0, function () {
4887
+ this.addToCartPromise = function (product, quantity, variant_id, comments) { return __awaiter$5(_this, void 0, void 0, function () {
4873
4888
  var added, result;
4874
4889
  return __generator$5(this, function (_a) {
4875
4890
  switch (_a.label) {
@@ -4879,7 +4894,7 @@
4879
4894
  return [2 /*return*/];
4880
4895
  }
4881
4896
  this.requestInProcess.next(true);
4882
- added = this.addIfAllreadyExists(product, variant_id, quantity);
4897
+ added = this.addIfAllreadyExists(product, variant_id, quantity, comments);
4883
4898
  if (!!added) return [3 /*break*/, 2];
4884
4899
  return [4 /*yield*/, (this.connection.post(this.addItemApi(), { productCode: product.id, quantity: quantity, variantCode: variant_id }).toPromise())];
4885
4900
  case 1:
@@ -4925,13 +4940,18 @@
4925
4940
  items = items.filter(function (itemParam) { return !_this.items.find(function (item) { return itemParam.variantCode == item.variant_id; }); });
4926
4941
  return __spread$3(items, paramsMerge);
4927
4942
  };
4928
- this.updateItemQuantity = function (item, quantity) {
4943
+ this.updateItemQuantity = function (item, quantity, comments) {
4929
4944
  if (_this.validateQuantity(item, quantity) && (_this.validatePriceAndCredits(item, quantity))) {
4930
4945
  _this.requestInProcess.next(true);
4946
+ var payload = { quantity: Number(quantity) };
4947
+ if (comments !== undefined) {
4948
+ var cleaned = ((comments !== null && comments !== void 0 ? comments : '')).trim();
4949
+ payload.comments = cleaned;
4950
+ }
4931
4951
  _this.connection
4932
- .put(_this.updateItemQuantityApi(_this.findItemByIdVariant(item.variant_id)), { 'quantity': Number(quantity) })
4952
+ .put(_this.updateItemQuantityApi(_this.findItemByIdVariant(item.variant_id)), payload)
4933
4953
  .pipe(operators.finalize(function () { return _this.requestInProcess.next(false); }))
4934
- .subscribe(function (res) { return _this.updateCartObj(res) && _this.updateCartItemQuantity(item.variant_id, Number(quantity)); }, function (err) { return _this.handleError(err); });
4954
+ .subscribe(function (res) { return _this.updateCartObj(res) && _this.updateCartItemQuantity(item.variant_id, Number(quantity), comments); }, function (err) { return _this.handleError(err); });
4935
4955
  }
4936
4956
  };
4937
4957
  this.validateQuantity = function (item, quantity) {
@@ -7578,7 +7598,7 @@
7578
7598
  };
7579
7599
  CartEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
7580
7600
  var _this = this;
7581
- var _a;
7601
+ var _a, _b, _c;
7582
7602
  if (this.cartLoading) {
7583
7603
  return;
7584
7604
  }
@@ -7598,10 +7618,11 @@
7598
7618
  newQuantity = Math.round(newQuantity / step) * step;
7599
7619
  }
7600
7620
  }
7621
+ var keepSameComment = (_c = (_b = item) === null || _b === void 0 ? void 0 : _b.comments, (_c !== null && _c !== void 0 ? _c : undefined));
7601
7622
  if (id) {
7602
7623
  this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
7603
7624
  if (newQuantity > 0 && newQuantity <= stock) {
7604
- this.cartService.updateItemQuantity(item, newQuantity);
7625
+ this.cartService.updateItemQuantity(item, newQuantity, keepSameComment);
7605
7626
  }
7606
7627
  else {
7607
7628
  this.toastrService.show('out-of-stock-actually');
@@ -7612,7 +7633,7 @@
7612
7633
  }
7613
7634
  else {
7614
7635
  if (newQuantity > 0 && newQuantity <= stock) {
7615
- this.cartService.updateItemQuantity(item, newQuantity);
7636
+ this.cartService.updateItemQuantity(item, newQuantity, keepSameComment);
7616
7637
  }
7617
7638
  else {
7618
7639
  this.toastrService.show('out-of-stock-actually');
@@ -8177,18 +8198,24 @@
8177
8198
  * @returns un arreglo de countries.
8178
8199
  */
8179
8200
  _this.filterCountryByCode = function (countries) {
8201
+ // 1. Si hay países EXCLUIDOS, quítalos siempre
8202
+ var filtered = countries;
8203
+ if (_this.consts.excludedCountries && _this.consts.excludedCountries.length > 0) {
8204
+ filtered = filtered.filter(function (elem) { return !_this.consts.excludedCountries.includes(elem.code); });
8205
+ }
8206
+ // 2. Si hay países INCLUIDOS, aplica el filtro de inclusión
8180
8207
  if (_this.consts.getCountries().length > 0) {
8181
- var countriesFiltered = countries.filter(function (elem) { return _this.consts.getCountries().includes(elem.code); });
8208
+ var countriesFiltered = filtered.filter(function (elem) { return _this.consts.getCountries().includes(elem.code); });
8182
8209
  if (countriesFiltered.length > 0) {
8183
8210
  return countriesFiltered;
8184
8211
  }
8185
8212
  else {
8186
8213
  console.error('El/los codigo/s ingresado/s no coinciden con los provistos desde el backend');
8187
- return countries;
8214
+ return filtered;
8188
8215
  }
8189
8216
  }
8190
8217
  else {
8191
- return countries;
8218
+ return filtered;
8192
8219
  }
8193
8220
  };
8194
8221
  _this.showFormFacturacion = function () {
@@ -11181,6 +11208,22 @@
11181
11208
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11182
11209
  return c > 3 && r && Object.defineProperty(target, key, r), r;
11183
11210
  };
11211
+ var __read$7 = (this && this.__read) || function (o, n) {
11212
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
11213
+ if (!m) return o;
11214
+ var i = m.call(o), r, ar = [], e;
11215
+ try {
11216
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
11217
+ }
11218
+ catch (error) { e = { error: error }; }
11219
+ finally {
11220
+ try {
11221
+ if (r && !r.done && (m = i["return"])) m.call(i);
11222
+ }
11223
+ finally { if (e) throw e.error; }
11224
+ }
11225
+ return ar;
11226
+ };
11184
11227
  var ProductDetailEcComponent = /** @class */ (function (_super) {
11185
11228
  __extends$w(ProductDetailEcComponent, _super);
11186
11229
  function ProductDetailEcComponent(productService, consts, activedRoute, cartService, optionsService, productsService, analyticsService, router, toastrService, meta, injector) {
@@ -11209,7 +11252,8 @@
11209
11252
  _this.enableFieldNotesInArticleFile = false;
11210
11253
  _this.addToCart = function () {
11211
11254
  var _a;
11212
- _this.quantity > 0 && _this.productService.addToCart(_this.quantity, undefined, ((_a = _this.comments) === null || _a === void 0 ? void 0 : _a.trim()) || null);
11255
+ var note = ((_a = _this.comments) === null || _a === void 0 ? void 0 : _a.trim()) || null;
11256
+ _this.quantity > 0 && _this.productService.addToCart(_this.quantity, undefined, note);
11213
11257
  };
11214
11258
  _this.addAllProductosToCart = function () {
11215
11259
  var _a, _b;
@@ -11333,7 +11377,31 @@
11333
11377
  return cadena.replace(expresionRegular, '');
11334
11378
  };
11335
11379
  ProductDetailEcComponent.prototype.ngOnInit = function () {
11380
+ var _this = this;
11336
11381
  this.ecOnInit();
11382
+ // Prellenar comentarios cuando:
11383
+ // - cargue el producto
11384
+ // - cambie la variante seleccionada (asociatedData$)
11385
+ // - cambien los ítems del carrito
11386
+ this.prefillSub = rxjs.combineLatest([
11387
+ this.productService.product$.pipe(operators.filter(function (p) { return !!p && !!p.id; })),
11388
+ this.productService.asociatedData$.pipe(operators.startWith(null)),
11389
+ this.cartService.cartItems.pipe(operators.startWith([])),
11390
+ ]).subscribe(function (_a) {
11391
+ var _b = __read$7(_a, 3), product = _b[0], data = _b[1], items = _b[2];
11392
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
11393
+ var variantId = (_k = (_f = (_d = (_c = data) === null || _c === void 0 ? void 0 : _c.variantCode, (_d !== null && _d !== void 0 ? _d : (_e = data) === null || _e === void 0 ? void 0 : _e.variant_id)), (_f !== null && _f !== void 0 ? _f : (_j = (_h = (_g = product) === null || _g === void 0 ? void 0 : _g.variants) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.code)), (_k !== null && _k !== void 0 ? _k : null));
11394
+ var match = (_l = items) === null || _l === void 0 ? void 0 : _l.find(function (it) {
11395
+ var _a, _b, _c, _d;
11396
+ return ((_b = (_a = it) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.id) === ((_c = product) === null || _c === void 0 ? void 0 : _c.id) &&
11397
+ (variantId ? ((_d = it) === null || _d === void 0 ? void 0 : _d.variant_id) === variantId : true);
11398
+ });
11399
+ _this.comments = (_o = (_m = match) === null || _m === void 0 ? void 0 : _m.comments, (_o !== null && _o !== void 0 ? _o : ''));
11400
+ });
11401
+ };
11402
+ ProductDetailEcComponent.prototype.ngOnDestroy = function () {
11403
+ var _a;
11404
+ (_a = this.prefillSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
11337
11405
  };
11338
11406
  ProductDetailEcComponent.prototype.scroll = function () {
11339
11407
  var el = this.contact.nativeElement;
@@ -11482,7 +11550,6 @@
11482
11550
  ProductEcComponent.prototype.ngOnChanges = function () {
11483
11551
  };
11484
11552
  ProductEcComponent.prototype.selectItem = function (product) {
11485
- console.log('entro');
11486
11553
  this.analyticsService.callEvent('select_item', product);
11487
11554
  };
11488
11555
  ProductEcComponent.ctorParameters = function () { return [
@@ -12753,7 +12820,7 @@
12753
12820
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
12754
12821
  return c > 3 && r && Object.defineProperty(target, key, r), r;
12755
12822
  };
12756
- var __read$7 = (this && this.__read) || function (o, n) {
12823
+ var __read$8 = (this && this.__read) || function (o, n) {
12757
12824
  var m = typeof Symbol === "function" && o[Symbol.iterator];
12758
12825
  if (!m) return o;
12759
12826
  var i = m.call(o), r, ar = [], e;
@@ -12797,7 +12864,7 @@
12797
12864
  var _this = this;
12798
12865
  var state;
12799
12866
  rxjs.combineLatest([this.activedRoute.params, this.activedRoute.queryParams]).subscribe(function (_a) {
12800
- var _b = __read$7(_a, 2), queryRouter = _b[0], queryParams = _b[1];
12867
+ var _b = __read$8(_a, 2), queryRouter = _b[0], queryParams = _b[1];
12801
12868
  state = queryRouter.state;
12802
12869
  state && state == 'statuspayment' && (state = queryParams.status);
12803
12870
  console.log('PARAMETROS STATE -> ', state);
@@ -15420,12 +15487,10 @@
15420
15487
  _this.loading = false;
15421
15488
  }
15422
15489
  else {
15423
- /* console.log('Entro al else'); */
15424
15490
  _this.renderPayPal();
15425
15491
  }
15426
15492
  }
15427
15493
  catch (error) {
15428
- /* console.log('Entro al catch'); */
15429
15494
  _this.renderPayPal();
15430
15495
  }
15431
15496
  }, 1000);
@@ -16098,7 +16163,7 @@
16098
16163
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16099
16164
  return c > 3 && r && Object.defineProperty(target, key, r), r;
16100
16165
  };
16101
- var __read$8 = (this && this.__read) || function (o, n) {
16166
+ var __read$9 = (this && this.__read) || function (o, n) {
16102
16167
  var m = typeof Symbol === "function" && o[Symbol.iterator];
16103
16168
  if (!m) return o;
16104
16169
  var i = m.call(o), r, ar = [], e;
@@ -16130,7 +16195,7 @@
16130
16195
  var _this = this;
16131
16196
  var token;
16132
16197
  rxjs.combineLatest([this.activedRoute.params, this.activedRoute.queryParams]).subscribe(function (_a) {
16133
- var _b = __read$8(_a, 2), queryRouter = _b[0], queryParams = _b[1];
16198
+ var _b = __read$9(_a, 2), queryRouter = _b[0], queryParams = _b[1];
16134
16199
  token = queryRouter.token;
16135
16200
  console.log('PARAMETROS token -> ', token);
16136
16201
  _this.cartService.loadCartByToken(token).then(function (res) {
@@ -19276,7 +19341,7 @@
19276
19341
  });
19277
19342
  };
19278
19343
  SidebarEcComponent.prototype.actualizarCantidad = function (item, cantidad, stock, id) {
19279
- var _a;
19344
+ var _a, _b, _c;
19280
19345
  if (this.cartLoading) {
19281
19346
  return;
19282
19347
  }
@@ -19296,13 +19361,14 @@
19296
19361
  newQuantity = Math.round(newQuantity / step) * step;
19297
19362
  }
19298
19363
  }
19364
+ var keepSameComment = (_c = (_b = item) === null || _b === void 0 ? void 0 : _b.comments, (_c !== null && _c !== void 0 ? _c : undefined));
19299
19365
  if (id) {
19300
19366
  var elem_1 = document.getElementById(id);
19301
19367
  if (elem_1) {
19302
19368
  elem_1.disabled = true;
19303
19369
  }
19304
19370
  if (newQuantity > 0 && newQuantity <= stock) {
19305
- this.cartService.updateItemQuantity(item, newQuantity);
19371
+ this.cartService.updateItemQuantity(item, newQuantity, keepSameComment);
19306
19372
  }
19307
19373
  else {
19308
19374
  this.toastrService.show('out-of-stock-actually');
@@ -19315,7 +19381,7 @@
19315
19381
  }
19316
19382
  else {
19317
19383
  if (newQuantity > 0 && newQuantity <= stock) {
19318
- this.cartService.updateItemQuantity(item, newQuantity);
19384
+ this.cartService.updateItemQuantity(item, newQuantity, keepSameComment);
19319
19385
  }
19320
19386
  }
19321
19387
  };
@@ -20114,7 +20180,7 @@
20114
20180
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
20115
20181
  return c > 3 && r && Object.defineProperty(target, key, r), r;
20116
20182
  };
20117
- var __read$9 = (this && this.__read) || function (o, n) {
20183
+ var __read$a = (this && this.__read) || function (o, n) {
20118
20184
  var m = typeof Symbol === "function" && o[Symbol.iterator];
20119
20185
  if (!m) return o;
20120
20186
  var i = m.call(o), r, ar = [], e;
@@ -20180,7 +20246,7 @@
20180
20246
  var forceShow = mode === 'alwaysShowDecimals';
20181
20247
  var forceHide = mode === 'alwaysHideDecimals';
20182
20248
  var showDecimals = forceShow ? true : forceHide ? false : !withoutDecimalGlobal;
20183
- var _b = __read$9((value || '').split(','), 2), ent = _b[0], _c = _b[1], dec = _c === void 0 ? '00' : _c;
20249
+ var _b = __read$a((value || '').split(','), 2), ent = _b[0], _c = _b[1], dec = _c === void 0 ? '00' : _c;
20184
20250
  if (showDecimals) {
20185
20251
  if (dec.length > 2)
20186
20252
  dec = dec.slice(0, 2);