ng-easycommerce 0.0.596 → 0.0.598

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.
@@ -563,6 +563,15 @@ var Constants = /** @class */ (function () {
563
563
  return _this.sortFilters = filtersCode;
564
564
  };
565
565
  this.getSortFilters = function () { return _this.sortFilters; };
566
+ this.postalCodePatterns = {
567
+ 'AR': /^[0-9]{4}$/,
568
+ 'UY': /^[0-9]{5}$/,
569
+ 'GB': /^[A-Z]{1,2}[0-9][A-Z0-9]?\s?[0-9][A-Z]{2}$/,
570
+ 'ES': /^(?:0[1-9]|[1-4]\d|5[0-2])\d{3}$/,
571
+ 'BR': /^[0-9]{5}-[0-9]{3}$/,
572
+ 'FR': /^[0-9]{5}$/,
573
+ 'PT': /^[0-9]{4}-[0-9]{3}$/,
574
+ };
566
575
  }
567
576
  /**
568
577
  *
@@ -600,6 +609,9 @@ var Constants = /** @class */ (function () {
600
609
  : params.find(function (param) { return param.code == (prefix + searched + suffix) || param.code == searched; });
601
610
  };
602
611
  ;
612
+ Constants$1.prototype.getPostalCodePattern = function (countryCode) {
613
+ return this.postalCodePatterns[countryCode] || /^[A-Za-z0-9\s\-]+$/;
614
+ };
603
615
  Constants$1.ctorParameters = function () { return [
604
616
  { type: TranslateService },
605
617
  { type: Router },
@@ -8037,7 +8049,7 @@ var DataFormEcComponent = /** @class */ (function (_super) {
8037
8049
  _this.viewDataFacturacion = true;
8038
8050
  _this.params = {};
8039
8051
  _this.selectAddres = false;
8040
- _this.postalCodePattern = '^[0-9][0-9]*$';
8052
+ _this.postalCodePattern = '^[A-Z]?[0-9]{4}[A-Z]{0,3}$';
8041
8053
  /**
8042
8054
  * @description filtra los paises de acuerdo al a los codigos retornados en la funcion getCountries.
8043
8055
  * Casos de usos: Si getCountries es vacio, retorna el arreglo que ingresa por parametro.
@@ -8087,6 +8099,10 @@ var DataFormEcComponent = /** @class */ (function (_super) {
8087
8099
  _this.checkoutForm.controls['countryCode'].setValue(value == 'null' ? null : value);
8088
8100
  _this.checkoutForm.controls['provinceCode'].setValue(null);
8089
8101
  _this.checkoutForm.controls['documentType'].setValue('');
8102
+ var selectedCountry = _this.countriesSubject.value.find(function (country) { return country.code == value; });
8103
+ if (selectedCountry) {
8104
+ _this.updatePostalCodeValidation(selectedCountry.code);
8105
+ }
8090
8106
  //Provinces
8091
8107
  var provinces = value && value != 'null' ?
8092
8108
  _this.countriesSubject.value.find(function (country) { return country.code == value; }).provinces
@@ -8265,12 +8281,12 @@ var DataFormEcComponent = /** @class */ (function (_super) {
8265
8281
  _this.getLabelNotesParam = function () { return _this.hasParams(_this.params, 'label_notes_' + _this.consts.getChannel() + '_' + _this.consts.getLocale().split('_')[0]); };
8266
8282
  _this.getParamByChannelAndLanguage = function (nameParam) { return _this.hasParams(_this.params, nameParam + _this.consts.getChannel() + '_' + _this.consts.getLocale().split('_')[0]); };
8267
8283
  _this.ecOnConstruct();
8268
- _this.checkoutForm = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formAddres), { postcode: ['', [Validators.required, Validators.pattern(_this.postalCodePattern)]] // Se agrega para que sólo acepte códigos postales mayores que cero
8284
+ _this.checkoutForm = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formAddres), { postcode: ['', [Validators.required]] // Se agrega para que sólo acepte códigos postales mayores que cero
8269
8285
  }));
8270
8286
  _this.checkoutForm.statusChanges
8271
8287
  .pipe(filter(function () { _this.onFormChange(); return _this.checkoutForm.valid; }))
8272
8288
  .subscribe(function () { return _this.onFormValid(); });
8273
- _this.checkoutFormFacturacion = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formBilling), { postcode: ['', [Validators.required, Validators.pattern(_this.postalCodePattern)]] // Se agrega para que sólo acepte códigos postales mayores que cero
8289
+ _this.checkoutFormFacturacion = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formBilling), { postcode: ['', [Validators.required]] // Se agrega para que sólo acepte códigos postales mayores que cero
8274
8290
  }));
8275
8291
  _this.checkoutFormFacturacion.statusChanges
8276
8292
  .pipe(filter(function () { _this.onFormChange(); return _this.checkoutFormFacturacion.valid; }))
@@ -8290,15 +8306,27 @@ var DataFormEcComponent = /** @class */ (function (_super) {
8290
8306
  _this.countriesSubject.next(countries);
8291
8307
  _this.countriesFacturacionSubject.next(countries);
8292
8308
  });
8293
- (this.addressingService.modeSelectAddress == 'LOAD_ADDRESS_AND_SELECTION' || this.addressingService.modeSelectAddress == 'ONLY_ADDRESS_SELECTION')
8294
- && this.addressingService.getAddressBook().then(function (res) {
8295
- _this.addressBook = res && res || null;
8296
- _this.addressBook == null && _this.setMode('carga');
8309
+ if (this.addressingService.modeSelectAddress === 'LOAD_ADDRESS_AND_SELECTION' ||
8310
+ this.addressingService.modeSelectAddress === 'ONLY_ADDRESS_SELECTION') {
8311
+ this.addressingService.getAddressBook().then(function (res) {
8312
+ _this.addressBook = res || null;
8313
+ if (_this.addressBook) {
8314
+ var selectedAddress = _this.addressBook.find(function (address) { return address.selected; });
8315
+ if (selectedAddress) {
8316
+ _this.checkoutForm.controls['countryCode'].setValue(selectedAddress.countryCode);
8317
+ _this.updatePostalCodeValidation(selectedAddress.countryCode);
8318
+ }
8319
+ }
8320
+ else {
8321
+ _this.setMode('carga');
8322
+ }
8297
8323
  });
8324
+ }
8298
8325
  this.countries$.subscribe(function (res) {
8299
8326
  var _a, _b, _c, _d;
8300
8327
  if (res && res.length > 0) {
8301
8328
  _this.checkoutForm.controls['countryCode'].setValue(res[0].code);
8329
+ _this.updatePostalCodeValidation(res[0].code);
8302
8330
  // Provincia
8303
8331
  _this.checkoutForm.controls['provinceCode'].setValue((_a = res[0]) === null || _a === void 0 ? void 0 : _a.provinces[0].code);
8304
8332
  _this.provincesSubject.next((_b = res[0]) === null || _b === void 0 ? void 0 : _b.provinces);
@@ -8325,6 +8353,14 @@ var DataFormEcComponent = /** @class */ (function (_super) {
8325
8353
  DataFormEcComponent.prototype.openModal = function (template) {
8326
8354
  this.modalRef = this.modalService.show(template, { class: 'modal-lg ', keyboard: false, backdrop: 'static' });
8327
8355
  };
8356
+ DataFormEcComponent.prototype.updatePostalCodeValidation = function (countryCode) {
8357
+ var postalCodePattern = this.consts.getPostalCodePattern(countryCode) || '.*';
8358
+ this.checkoutForm.controls['postcode'].setValidators([
8359
+ Validators.required,
8360
+ Validators.pattern(postalCodePattern)
8361
+ ]);
8362
+ this.checkoutForm.controls['postcode'].updateValueAndValidity();
8363
+ };
8328
8364
  DataFormEcComponent.prototype.prueba = function (x) {
8329
8365
  console.log(x);
8330
8366
  };
@@ -14132,15 +14168,18 @@ var __decorate$1u = (this && this.__decorate) || function (decorators, target, k
14132
14168
  };
14133
14169
  var DetailCheckoutBlockEcComponent = /** @class */ (function (_super) {
14134
14170
  __extends$V(DetailCheckoutBlockEcComponent, _super);
14135
- function DetailCheckoutBlockEcComponent(checkoutService, cartService) {
14171
+ function DetailCheckoutBlockEcComponent(checkoutService, cartService, channelConfigService) {
14136
14172
  var _this = _super.call(this) || this;
14137
14173
  _this.checkoutService = checkoutService;
14138
14174
  _this.cartService = cartService;
14175
+ _this.channelConfigService = channelConfigService;
14139
14176
  _this.data = null;
14140
14177
  _this.discountTotal = 0;
14141
14178
  _this.couponTotal = 0;
14142
14179
  _this.showPrice = false;
14143
14180
  _this.creditAmountConfigured = false;
14181
+ _this.hideDiscounts = false;
14182
+ _this.hideTaxes = false;
14144
14183
  _this.getIcon = function (data_item) {
14145
14184
  switch (data_item.type) {
14146
14185
  case 'coupon': return 'fas fa-ticket-alt fa-3x';
@@ -14173,6 +14212,11 @@ var DetailCheckoutBlockEcComponent = /** @class */ (function (_super) {
14173
14212
  this.cartService.creditAmount$.subscribe(function (creditAmount) {
14174
14213
  _this.creditAmountConfigured = creditAmount !== null;
14175
14214
  });
14215
+ this.channelConfigService.channelConfig$.subscribe(function (channel) {
14216
+ var _a, _b, _c, _d;
14217
+ _this.hideDiscounts = (_b = (_a = channel) === null || _a === void 0 ? void 0 : _a.hideDiscounts, (_b !== null && _b !== void 0 ? _b : false));
14218
+ _this.hideTaxes = (_d = (_c = channel) === null || _c === void 0 ? void 0 : _c.hideTaxes, (_d !== null && _d !== void 0 ? _d : false));
14219
+ });
14176
14220
  };
14177
14221
  DetailCheckoutBlockEcComponent.prototype.calcularTotales = function () {
14178
14222
  if (this.data) {
@@ -14186,7 +14230,8 @@ var DetailCheckoutBlockEcComponent = /** @class */ (function (_super) {
14186
14230
  };
14187
14231
  DetailCheckoutBlockEcComponent.ctorParameters = function () { return [
14188
14232
  { type: CheckoutService },
14189
- { type: CartService }
14233
+ { type: CartService },
14234
+ { type: ChannelConfigService }
14190
14235
  ]; };
14191
14236
  __decorate$1u([
14192
14237
  Input()
@@ -14194,7 +14239,7 @@ var DetailCheckoutBlockEcComponent = /** @class */ (function (_super) {
14194
14239
  DetailCheckoutBlockEcComponent = __decorate$1u([
14195
14240
  Component({
14196
14241
  selector: 'app-detail-checkout-block-ec',
14197
- template: "<div id=\"appDetailCheckoutBlockEc\" class=\"d-flex flex-row w-100 justify-content-center flex-wrap\"\n *ngIf=\"data && (creditAmountConfigured ? showPrice : true)\">\n <ng-container *ngFor=\"let item of data; let i = index\">\n <ng-container *ngIf=\"item.type != 'discount' && item.type != 'coupon'\">\n <div class=\"d-flex flex-column justify-content-center mx-sm-3 mx-2 text-center mb-4 resumen\">\n <i ngClass=\"mb-2 colorIconoCheckout\" [class]=\"getIcon(item)\"></i>\n <strong class=\"text-center w-100 font-brandon font-md mb-1\">{{ item.type | translate }}</strong>\n <span class=\"text-center w-100 font-brandon font-md text-gray\">{{ (item.amount != 0 ) ? (item.amount |\n ecCurrencySymbol) : ('free' | translate) }}</span>\n </div>\n </ng-container>\n\n\n <!-- Mostrar total de descuentos -->\n <div class=\"d-flex flex-column justify-content-center mx-sm-3 mx-2 text-center mb-4 resumen\"\n *ngIf=\"this.discountTotal != 0 && i === 1\">\n <i ngClass=\"mb-2 colorIconoCheckout\" [class]=\"getIcon2('discount')\"></i>\n <strong class=\"text-center w-100 font-brandon font-md mb-1\">Descuento</strong>\n <span class=\"text-center w-100 font-brandon font-md text-gray\">{{ (this.discountTotal | ecCurrencySymbol)\n }}</span>\n </div>\n\n <!-- Mostrar total de cupones -->\n <div class=\"d-flex flex-column justify-content-center mx-sm-3 mx-2 text-center mb-4 resumen\"\n *ngIf=\"this.couponTotal != 0 && i === 1\">\n <i ngClass=\"mb-2 colorIconoCheckout\" [class]=\"getIcon2('coupon')\"></i>\n <strong class=\"text-center w-100 font-brandon font-md mb-1\">Cupon</strong>\n <span class=\"text-center w-100 font-brandon font-md text-gray\">{{(this.couponTotal| ecCurrencySymbol)\n }}</span>\n </div>\n </ng-container>\n</div>",
14242
+ template: "<div id=\"appDetailCheckoutBlockEc\" class=\"d-flex flex-row w-100 justify-content-center flex-wrap\"\n *ngIf=\"data && (creditAmountConfigured ? showPrice : true)\">\n <ng-container *ngFor=\"let item of data; let i = index\">\n <ng-container *ngIf=\"item.type != 'discount' && item.type != 'coupon'\">\n <div class=\"d-flex flex-column justify-content-center mx-sm-3 mx-2 text-center mb-4 resumen\">\n <i ngClass=\"mb-2 colorIconoCheckout\" [class]=\"getIcon(item)\"></i>\n <strong class=\"text-center w-100 font-brandon font-md mb-1\">{{ item.type | translate }}</strong>\n <span class=\"text-center w-100 font-brandon font-md text-gray\">{{ (item.amount != 0 ) ? (item.amount |\n ecCurrencySymbol) : ('free' | translate) }}</span>\n </div>\n </ng-container>\n\n\n <!-- Mostrar total de descuentos -->\n <div class=\"d-flex flex-column justify-content-center mx-sm-3 mx-2 text-center mb-4 resumen\"\n *ngIf=\"!hideDiscounts && this.discountTotal != 0 && i === 1\">\n <i ngClass=\"mb-2 colorIconoCheckout\" [class]=\"getIcon2('discount')\"></i>\n <strong class=\"text-center w-100 font-brandon font-md mb-1\">Descuento</strong>\n <span class=\"text-center w-100 font-brandon font-md text-gray\">{{ (this.discountTotal | ecCurrencySymbol)\n }}</span>\n </div>\n\n <!-- Mostrar total de cupones -->\n <div class=\"d-flex flex-column justify-content-center mx-sm-3 mx-2 text-center mb-4 resumen\"\n *ngIf=\"!hideDiscounts && this.couponTotal != 0 && i === 1\">\n <i ngClass=\"mb-2 colorIconoCheckout\" [class]=\"getIcon2('coupon')\"></i>\n <strong class=\"text-center w-100 font-brandon font-md mb-1\">Cupon</strong>\n <span class=\"text-center w-100 font-brandon font-md text-gray\">{{(this.couponTotal| ecCurrencySymbol)\n }}</span>\n </div>\n </ng-container>\n</div>",
14198
14243
  styles: [""]
14199
14244
  })
14200
14245
  ], DetailCheckoutBlockEcComponent);
@@ -18515,16 +18560,19 @@ var __decorate$1$ = (this && this.__decorate) || function (decorators, target, k
18515
18560
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18516
18561
  };
18517
18562
  var SidebarEcComponent = /** @class */ (function () {
18518
- function SidebarEcComponent(cartService, consts, authService, router, toastrService) {
18563
+ function SidebarEcComponent(cartService, consts, authService, router, toastrService, channelConfigService) {
18519
18564
  var _this = this;
18520
18565
  this.cartService = cartService;
18521
18566
  this.consts = consts;
18522
18567
  this.authService = authService;
18523
18568
  this.router = router;
18524
18569
  this.toastrService = toastrService;
18570
+ this.channelConfigService = channelConfigService;
18525
18571
  this.user = null;
18526
18572
  this.promotions = [];
18527
18573
  this.variantsToShow = ['TALLE', 'COLOR'];
18574
+ this.hideDiscounts = false;
18575
+ this.hideTaxes = false;
18528
18576
  this.actualizarCantidad = function (item, cantidad, stock, id) {
18529
18577
  if (id) {
18530
18578
  var elem_1 = document.getElementById(id);
@@ -18588,6 +18636,11 @@ var SidebarEcComponent = /** @class */ (function () {
18588
18636
  this.authService.getUserProfile().subscribe(function (u) {
18589
18637
  _this.user = u;
18590
18638
  });
18639
+ this.channelConfigService.channelConfig$.subscribe(function (channel) {
18640
+ var _a, _b, _c, _d;
18641
+ _this.hideDiscounts = (_b = (_a = channel) === null || _a === void 0 ? void 0 : _a.hideDiscounts, (_b !== null && _b !== void 0 ? _b : false));
18642
+ _this.hideTaxes = (_d = (_c = channel) === null || _c === void 0 ? void 0 : _c.hideTaxes, (_d !== null && _d !== void 0 ? _d : false));
18643
+ });
18591
18644
  };
18592
18645
  SidebarEcComponent.prototype.redirectDetailProduct = function (product) {
18593
18646
  var variant = product.variants[0];
@@ -18609,7 +18662,8 @@ var SidebarEcComponent = /** @class */ (function () {
18609
18662
  { type: Constants },
18610
18663
  { type: AuthService },
18611
18664
  { type: Router },
18612
- { type: ToastService }
18665
+ { type: ToastService },
18666
+ { type: ChannelConfigService }
18613
18667
  ]; };
18614
18668
  SidebarEcComponent = __decorate$1$([
18615
18669
  Component({