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/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
# version 0.0.598
|
|
2
|
+
- Se implementa la validación de códigos postales según el país seleccionado en el formulario de checkout.
|
|
3
|
+
- Se agrega la lógica en `dataform-ec.component.ts` para establecer patrones de validación dinámicos de acuerdo con el país.
|
|
4
|
+
- Se obtiene el código del país seleccionado en el formulario y se aplica la validación correspondiente.
|
|
5
|
+
- Se añaden patrones de validación para los códigos postales de Argentina, Uruguay, Reino Unido, España, Brasil, Francia y Portugal.
|
|
1
6
|
# version 0.0.597
|
|
2
7
|
- Se integran los parámetros `hideDiscounts` y `hideTaxes` del servicio `channel-config.service.ts` en el componente `sidebar-ec.component.ts` y `detail-checkout-block-ec.component.ts`
|
|
3
8
|
# version 0.0.596
|
|
@@ -549,6 +549,15 @@
|
|
|
549
549
|
return _this.sortFilters = filtersCode;
|
|
550
550
|
};
|
|
551
551
|
this.getSortFilters = function () { return _this.sortFilters; };
|
|
552
|
+
this.postalCodePatterns = {
|
|
553
|
+
'AR': /^[0-9]{4}$/,
|
|
554
|
+
'UY': /^[0-9]{5}$/,
|
|
555
|
+
'GB': /^[A-Z]{1,2}[0-9][A-Z0-9]?\s?[0-9][A-Z]{2}$/,
|
|
556
|
+
'ES': /^(?:0[1-9]|[1-4]\d|5[0-2])\d{3}$/,
|
|
557
|
+
'BR': /^[0-9]{5}-[0-9]{3}$/,
|
|
558
|
+
'FR': /^[0-9]{5}$/,
|
|
559
|
+
'PT': /^[0-9]{4}-[0-9]{3}$/,
|
|
560
|
+
};
|
|
552
561
|
}
|
|
553
562
|
/**
|
|
554
563
|
*
|
|
@@ -586,6 +595,9 @@
|
|
|
586
595
|
: params.find(function (param) { return param.code == (prefix + searched + suffix) || param.code == searched; });
|
|
587
596
|
};
|
|
588
597
|
;
|
|
598
|
+
Constants$1.prototype.getPostalCodePattern = function (countryCode) {
|
|
599
|
+
return this.postalCodePatterns[countryCode] || /^[A-Za-z0-9\s\-]+$/;
|
|
600
|
+
};
|
|
589
601
|
Constants$1.ctorParameters = function () { return [
|
|
590
602
|
{ type: core$1.TranslateService },
|
|
591
603
|
{ type: router.Router },
|
|
@@ -8023,7 +8035,7 @@
|
|
|
8023
8035
|
_this.viewDataFacturacion = true;
|
|
8024
8036
|
_this.params = {};
|
|
8025
8037
|
_this.selectAddres = false;
|
|
8026
|
-
_this.postalCodePattern = '^[
|
|
8038
|
+
_this.postalCodePattern = '^[A-Z]?[0-9]{4}[A-Z]{0,3}$';
|
|
8027
8039
|
/**
|
|
8028
8040
|
* @description filtra los paises de acuerdo al a los codigos retornados en la funcion getCountries.
|
|
8029
8041
|
* Casos de usos: Si getCountries es vacio, retorna el arreglo que ingresa por parametro.
|
|
@@ -8073,6 +8085,10 @@
|
|
|
8073
8085
|
_this.checkoutForm.controls['countryCode'].setValue(value == 'null' ? null : value);
|
|
8074
8086
|
_this.checkoutForm.controls['provinceCode'].setValue(null);
|
|
8075
8087
|
_this.checkoutForm.controls['documentType'].setValue('');
|
|
8088
|
+
var selectedCountry = _this.countriesSubject.value.find(function (country) { return country.code == value; });
|
|
8089
|
+
if (selectedCountry) {
|
|
8090
|
+
_this.updatePostalCodeValidation(selectedCountry.code);
|
|
8091
|
+
}
|
|
8076
8092
|
//Provinces
|
|
8077
8093
|
var provinces = value && value != 'null' ?
|
|
8078
8094
|
_this.countriesSubject.value.find(function (country) { return country.code == value; }).provinces
|
|
@@ -8251,12 +8267,12 @@
|
|
|
8251
8267
|
_this.getLabelNotesParam = function () { return _this.hasParams(_this.params, 'label_notes_' + _this.consts.getChannel() + '_' + _this.consts.getLocale().split('_')[0]); };
|
|
8252
8268
|
_this.getParamByChannelAndLanguage = function (nameParam) { return _this.hasParams(_this.params, nameParam + _this.consts.getChannel() + '_' + _this.consts.getLocale().split('_')[0]); };
|
|
8253
8269
|
_this.ecOnConstruct();
|
|
8254
|
-
_this.checkoutForm = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formAddres), { postcode: ['', [forms.Validators.required
|
|
8270
|
+
_this.checkoutForm = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formAddres), { postcode: ['', [forms.Validators.required]] // Se agrega para que sólo acepte códigos postales mayores que cero
|
|
8255
8271
|
}));
|
|
8256
8272
|
_this.checkoutForm.statusChanges
|
|
8257
8273
|
.pipe(operators.filter(function () { _this.onFormChange(); return _this.checkoutForm.valid; }))
|
|
8258
8274
|
.subscribe(function () { return _this.onFormValid(); });
|
|
8259
|
-
_this.checkoutFormFacturacion = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formBilling), { postcode: ['', [forms.Validators.required
|
|
8275
|
+
_this.checkoutFormFacturacion = _this.fb.group(__assign$j(__assign$j({}, _this.addressingService.getTypeForm().configForm.formBilling), { postcode: ['', [forms.Validators.required]] // Se agrega para que sólo acepte códigos postales mayores que cero
|
|
8260
8276
|
}));
|
|
8261
8277
|
_this.checkoutFormFacturacion.statusChanges
|
|
8262
8278
|
.pipe(operators.filter(function () { _this.onFormChange(); return _this.checkoutFormFacturacion.valid; }))
|
|
@@ -8276,15 +8292,27 @@
|
|
|
8276
8292
|
_this.countriesSubject.next(countries);
|
|
8277
8293
|
_this.countriesFacturacionSubject.next(countries);
|
|
8278
8294
|
});
|
|
8279
|
-
(this.addressingService.modeSelectAddress
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
_this.addressBook
|
|
8295
|
+
if (this.addressingService.modeSelectAddress === 'LOAD_ADDRESS_AND_SELECTION' ||
|
|
8296
|
+
this.addressingService.modeSelectAddress === 'ONLY_ADDRESS_SELECTION') {
|
|
8297
|
+
this.addressingService.getAddressBook().then(function (res) {
|
|
8298
|
+
_this.addressBook = res || null;
|
|
8299
|
+
if (_this.addressBook) {
|
|
8300
|
+
var selectedAddress = _this.addressBook.find(function (address) { return address.selected; });
|
|
8301
|
+
if (selectedAddress) {
|
|
8302
|
+
_this.checkoutForm.controls['countryCode'].setValue(selectedAddress.countryCode);
|
|
8303
|
+
_this.updatePostalCodeValidation(selectedAddress.countryCode);
|
|
8304
|
+
}
|
|
8305
|
+
}
|
|
8306
|
+
else {
|
|
8307
|
+
_this.setMode('carga');
|
|
8308
|
+
}
|
|
8283
8309
|
});
|
|
8310
|
+
}
|
|
8284
8311
|
this.countries$.subscribe(function (res) {
|
|
8285
8312
|
var _a, _b, _c, _d;
|
|
8286
8313
|
if (res && res.length > 0) {
|
|
8287
8314
|
_this.checkoutForm.controls['countryCode'].setValue(res[0].code);
|
|
8315
|
+
_this.updatePostalCodeValidation(res[0].code);
|
|
8288
8316
|
// Provincia
|
|
8289
8317
|
_this.checkoutForm.controls['provinceCode'].setValue((_a = res[0]) === null || _a === void 0 ? void 0 : _a.provinces[0].code);
|
|
8290
8318
|
_this.provincesSubject.next((_b = res[0]) === null || _b === void 0 ? void 0 : _b.provinces);
|
|
@@ -8311,6 +8339,14 @@
|
|
|
8311
8339
|
DataFormEcComponent.prototype.openModal = function (template) {
|
|
8312
8340
|
this.modalRef = this.modalService.show(template, { class: 'modal-lg ', keyboard: false, backdrop: 'static' });
|
|
8313
8341
|
};
|
|
8342
|
+
DataFormEcComponent.prototype.updatePostalCodeValidation = function (countryCode) {
|
|
8343
|
+
var postalCodePattern = this.consts.getPostalCodePattern(countryCode) || '.*';
|
|
8344
|
+
this.checkoutForm.controls['postcode'].setValidators([
|
|
8345
|
+
forms.Validators.required,
|
|
8346
|
+
forms.Validators.pattern(postalCodePattern)
|
|
8347
|
+
]);
|
|
8348
|
+
this.checkoutForm.controls['postcode'].updateValueAndValidity();
|
|
8349
|
+
};
|
|
8314
8350
|
DataFormEcComponent.prototype.prueba = function (x) {
|
|
8315
8351
|
console.log(x);
|
|
8316
8352
|
};
|