ng-easycommerce 0.0.597 → 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.
- package/README.md +5 -0
- package/bundles/ng-easycommerce.umd.js +43 -7
- package/bundles/ng-easycommerce.umd.js.map +1 -1
- package/bundles/ng-easycommerce.umd.min.js +1 -1
- package/bundles/ng-easycommerce.umd.min.js.map +1 -1
- package/esm2015/lib/core.consts.js +13 -1
- package/esm2015/lib/ec-component/checkout-ec/dataform-ec/dataform-ec.component.js +32 -8
- package/esm5/lib/core.consts.js +13 -1
- package/esm5/lib/ec-component/checkout-ec/dataform-ec/dataform-ec.component.js +32 -8
- package/fesm2015/ng-easycommerce.js +43 -7
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +43 -7
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/core.consts.d.ts +2 -0
- package/lib/ec-component/checkout-ec/dataform-ec/dataform-ec.component.d.ts +1 -0
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
package/fesm5/ng-easycommerce.js
CHANGED
|
@@ -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 = '^[
|
|
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
|
|
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
|
|
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
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
_this.addressBook
|
|
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
|
};
|