ng-easycommerce 0.0.624 → 0.0.626
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 +10 -0
- package/bundles/ng-easycommerce.umd.js +211 -61
- 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/ec-component/auth-ec/register-form-ec/register-form-ec.component.js +94 -8
- package/esm2015/lib/ec-component/cart-ec/cart-ec.component.js +41 -23
- package/esm2015/lib/ec-component/sidebar-ec/sidebar-ec.component.js +42 -16
- package/esm2015/lib/services/cart.service.js +7 -1
- package/esm5/lib/ec-component/auth-ec/register-form-ec/register-form-ec.component.js +109 -8
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +42 -23
- package/esm5/lib/ec-component/sidebar-ec/sidebar-ec.component.js +42 -16
- package/esm5/lib/services/cart.service.js +7 -1
- package/fesm2015/ng-easycommerce.js +177 -43
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +211 -61
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/auth-ec/register-form-ec/register-form-ec.component.d.ts +17 -3
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +1 -1
- package/lib/ec-component/sidebar-ec/sidebar-ec.component.d.ts +1 -1
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -4168,6 +4168,12 @@ let CartService = class CartService {
|
|
|
4168
4168
|
this.toastrService.show('minimum-items-quantity', { quantity: item.product.variants[0].minimumItemsQuantity });
|
|
4169
4169
|
return false;
|
|
4170
4170
|
}
|
|
4171
|
+
if (item.product.variants[0].multipleQuantity && item.product.variants[0].multipleQuantity > 0) {
|
|
4172
|
+
if ((this.getCountFromItemInCart(item.productCode) + quantity) % item.product.variants[0].multipleQuantity !== 0) {
|
|
4173
|
+
this.toastrService.show('must-be-multiple', { quantity: item.product.variants[0].multipleQuantity });
|
|
4174
|
+
return false;
|
|
4175
|
+
}
|
|
4176
|
+
}
|
|
4171
4177
|
return true;
|
|
4172
4178
|
};
|
|
4173
4179
|
this.validatePriceAndCredits = (item, quantity) => {
|
|
@@ -6241,28 +6247,6 @@ let CartEcComponent = class CartEcComponent extends ComponentHelper {
|
|
|
6241
6247
|
this.creditAccountShowPrices = null;
|
|
6242
6248
|
this.showTaxLegend = false;
|
|
6243
6249
|
this.toDecimal = (amount) => this.consts.toDecimal(amount);
|
|
6244
|
-
this.actualizarCantidad = (item, cantidad, stock, id) => {
|
|
6245
|
-
if (id) {
|
|
6246
|
-
this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
|
|
6247
|
-
if (cantidad > 0 && cantidad <= stock) {
|
|
6248
|
-
this.cartService.updateItemQuantity(item, cantidad);
|
|
6249
|
-
}
|
|
6250
|
-
else {
|
|
6251
|
-
this.toastrService.show('out-of-stock-actually');
|
|
6252
|
-
}
|
|
6253
|
-
setTimeout(() => {
|
|
6254
|
-
this.isDisabled = false;
|
|
6255
|
-
}, 1000);
|
|
6256
|
-
}
|
|
6257
|
-
else {
|
|
6258
|
-
if (cantidad > 0 && cantidad <= stock) {
|
|
6259
|
-
this.cartService.updateItemQuantity(item, cantidad);
|
|
6260
|
-
}
|
|
6261
|
-
else {
|
|
6262
|
-
this.toastrService.show('out-of-stock-actually');
|
|
6263
|
-
}
|
|
6264
|
-
}
|
|
6265
|
-
};
|
|
6266
6250
|
this.redirectRegister = () => this.router.navigateByUrl(`/auth/login`);
|
|
6267
6251
|
this.getVariants = product => {
|
|
6268
6252
|
let item = product.product;
|
|
@@ -6337,6 +6321,46 @@ let CartEcComponent = class CartEcComponent extends ComponentHelper {
|
|
|
6337
6321
|
});
|
|
6338
6322
|
this.ecOnInit();
|
|
6339
6323
|
}
|
|
6324
|
+
actualizarCantidad(item, cantidad, stock, id) {
|
|
6325
|
+
var _a;
|
|
6326
|
+
const multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
|
|
6327
|
+
const step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
|
|
6328
|
+
let newQuantity;
|
|
6329
|
+
if (typeof cantidad === 'string') {
|
|
6330
|
+
newQuantity = parseInt(cantidad, 10);
|
|
6331
|
+
if (newQuantity % step !== 0) {
|
|
6332
|
+
this.toastrService.show('must-be-multiple', { quantity: step });
|
|
6333
|
+
newQuantity = Math.round(newQuantity / step) * step;
|
|
6334
|
+
}
|
|
6335
|
+
}
|
|
6336
|
+
else {
|
|
6337
|
+
newQuantity = cantidad;
|
|
6338
|
+
if (newQuantity % step !== 0) {
|
|
6339
|
+
newQuantity = Math.round(newQuantity / step) * step;
|
|
6340
|
+
}
|
|
6341
|
+
}
|
|
6342
|
+
if (id) {
|
|
6343
|
+
this.isDisabled = true; // Actualiza la propiedad vinculada a `[disabled]`
|
|
6344
|
+
if (newQuantity > 0 && newQuantity <= stock) {
|
|
6345
|
+
this.cartService.updateItemQuantity(item, newQuantity);
|
|
6346
|
+
}
|
|
6347
|
+
else {
|
|
6348
|
+
this.toastrService.show('out-of-stock-actually');
|
|
6349
|
+
}
|
|
6350
|
+
setTimeout(() => {
|
|
6351
|
+
this.isDisabled = false;
|
|
6352
|
+
}, 1000);
|
|
6353
|
+
}
|
|
6354
|
+
else {
|
|
6355
|
+
if (newQuantity > 0 && newQuantity <= stock) {
|
|
6356
|
+
this.cartService.updateItemQuantity(item, newQuantity);
|
|
6357
|
+
}
|
|
6358
|
+
else {
|
|
6359
|
+
this.toastrService.show('out-of-stock-actually');
|
|
6360
|
+
}
|
|
6361
|
+
}
|
|
6362
|
+
}
|
|
6363
|
+
;
|
|
6340
6364
|
redirectCheckout() {
|
|
6341
6365
|
if (this.cartService.hasSufficientCreditsForCartTotal()) {
|
|
6342
6366
|
this.router.navigateByUrl(`/checkout`);
|
|
@@ -11254,7 +11278,7 @@ var __decorate$1n = (this && this.__decorate) || function (decorators, target, k
|
|
|
11254
11278
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11255
11279
|
};
|
|
11256
11280
|
let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHelper {
|
|
11257
|
-
constructor(authService, toastr, router, analyticsService, formBuilder, channelConfigService) {
|
|
11281
|
+
constructor(authService, toastr, router, analyticsService, formBuilder, channelConfigService, consts) {
|
|
11258
11282
|
super();
|
|
11259
11283
|
this.authService = authService;
|
|
11260
11284
|
this.toastr = toastr;
|
|
@@ -11262,6 +11286,13 @@ let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHel
|
|
|
11262
11286
|
this.analyticsService = analyticsService;
|
|
11263
11287
|
this.formBuilder = formBuilder;
|
|
11264
11288
|
this.channelConfigService = channelConfigService;
|
|
11289
|
+
this.consts = consts;
|
|
11290
|
+
this.provincesSubject = new BehaviorSubject([]);
|
|
11291
|
+
this.countriesSubject = new BehaviorSubject([]);
|
|
11292
|
+
this.documentTypesSubject = new BehaviorSubject([]);
|
|
11293
|
+
this.provinces$ = this.provincesSubject.asObservable();
|
|
11294
|
+
this.countries$ = this.countriesSubject.asObservable();
|
|
11295
|
+
this.documentTypes$ = this.documentTypesSubject.asObservable();
|
|
11265
11296
|
this.isLogged = true;
|
|
11266
11297
|
this.darkMode = false;
|
|
11267
11298
|
this.redirect = true;
|
|
@@ -11303,7 +11334,8 @@ let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHel
|
|
|
11303
11334
|
return;
|
|
11304
11335
|
}
|
|
11305
11336
|
if (this.registerForm.valid) {
|
|
11306
|
-
this.
|
|
11337
|
+
const normalizedData = this.normalizeRegisterData(this.registerForm.value);
|
|
11338
|
+
this.authService.signUp(normalizedData).toPromise().then(res => {
|
|
11307
11339
|
this.register_loading = false;
|
|
11308
11340
|
let messageKey;
|
|
11309
11341
|
switch (true) {
|
|
@@ -11345,6 +11377,18 @@ let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHel
|
|
|
11345
11377
|
this.register_loading = false;
|
|
11346
11378
|
}
|
|
11347
11379
|
};
|
|
11380
|
+
this.onCountrySelected = (value) => {
|
|
11381
|
+
$('#selectOpPais').attr('disabled', true);
|
|
11382
|
+
this.registerForm.controls['countryCode'].setValue(value);
|
|
11383
|
+
this.registerForm.controls['provinceCode'].setValue('');
|
|
11384
|
+
value != '' && this.provincesSubject.next(this.countriesSubject.value.find(country => country.code == value).provinces);
|
|
11385
|
+
};
|
|
11386
|
+
this.onGenderSelected = (value) => {
|
|
11387
|
+
$('#selectOpSexo').attr('disabled', true);
|
|
11388
|
+
};
|
|
11389
|
+
this.onProvincesSelected = (value) => {
|
|
11390
|
+
$('#selectOpProvincia').attr('disabled', true);
|
|
11391
|
+
};
|
|
11348
11392
|
this.ecOnConstruct();
|
|
11349
11393
|
}
|
|
11350
11394
|
ngOnInit() {
|
|
@@ -11356,7 +11400,40 @@ let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHel
|
|
|
11356
11400
|
plainPassword2: ['', Validators.required],
|
|
11357
11401
|
newsletter: [false],
|
|
11358
11402
|
terms: ['', Validators.required],
|
|
11359
|
-
birthday: [
|
|
11403
|
+
birthday: [null, [this.optionalMaxLengthValidator(11)]],
|
|
11404
|
+
// Dirección (opcional, pero si se envía, se recomienda enviar todos los campos internos)
|
|
11405
|
+
countryCode: [''],
|
|
11406
|
+
provinceCode: [null],
|
|
11407
|
+
street: [null],
|
|
11408
|
+
city: [''],
|
|
11409
|
+
postcode: [''],
|
|
11410
|
+
// Datos empresa (opcionales)
|
|
11411
|
+
companyName: [''],
|
|
11412
|
+
legalDenomination: [''],
|
|
11413
|
+
// Datos personales adicionales (opcionales)
|
|
11414
|
+
gender: [null],
|
|
11415
|
+
phoneNumber: ['', [Validators.pattern('[0-9]+')]],
|
|
11416
|
+
subscribedToNewsletter: [false],
|
|
11417
|
+
documentType: [null],
|
|
11418
|
+
documentNumber: [''],
|
|
11419
|
+
// Comentarios y contacto (opcionales)
|
|
11420
|
+
comments: ['', []],
|
|
11421
|
+
contactFirstName: ['', []],
|
|
11422
|
+
contactLastName: ['', []],
|
|
11423
|
+
contactCompanyPosition: ['', []],
|
|
11424
|
+
contactEmail: ['', []],
|
|
11425
|
+
contactDocumentType: ['', []],
|
|
11426
|
+
contactDocumentNumber: ['', []],
|
|
11427
|
+
}, {
|
|
11428
|
+
validators: [this.direccionCompletaValidator()]
|
|
11429
|
+
});
|
|
11430
|
+
this.authService.getCountriesData().then(res => {
|
|
11431
|
+
this.countriesSubject.next(res);
|
|
11432
|
+
let documentTypes = [];
|
|
11433
|
+
res.map(paises => {
|
|
11434
|
+
this.consts.getLocale().toLocaleLowerCase().includes(paises.code.toLocaleLowerCase()) && (documentTypes = paises.documentTypes || []);
|
|
11435
|
+
});
|
|
11436
|
+
this.documentTypesSubject.next(documentTypes);
|
|
11360
11437
|
});
|
|
11361
11438
|
this.channelConfigService.channelConfig$.subscribe((config) => {
|
|
11362
11439
|
if (config && config.isAccountVerificationRequired !== undefined) {
|
|
@@ -11374,8 +11451,38 @@ let RegisterFormEcComponent = class RegisterFormEcComponent extends ComponentHel
|
|
|
11374
11451
|
});
|
|
11375
11452
|
this.ecOnInit();
|
|
11376
11453
|
}
|
|
11377
|
-
|
|
11378
|
-
|
|
11454
|
+
direccionCompletaValidator() {
|
|
11455
|
+
return (control) => {
|
|
11456
|
+
var _a, _b, _c, _d, _e;
|
|
11457
|
+
const street = (_a = control.get('street')) === null || _a === void 0 ? void 0 : _a.value;
|
|
11458
|
+
const city = (_b = control.get('city')) === null || _b === void 0 ? void 0 : _b.value;
|
|
11459
|
+
const provinceCode = (_c = control.get('provinceCode')) === null || _c === void 0 ? void 0 : _c.value;
|
|
11460
|
+
const countryCode = (_d = control.get('countryCode')) === null || _d === void 0 ? void 0 : _d.value;
|
|
11461
|
+
const postcode = (_e = control.get('postcode')) === null || _e === void 0 ? void 0 : _e.value;
|
|
11462
|
+
const hasValue = (val) => val !== null && val !== undefined && val.toString().trim() !== '';
|
|
11463
|
+
const anyFieldSet = [street, city, provinceCode, countryCode, postcode].some(hasValue);
|
|
11464
|
+
const allFieldsSet = [street, city, provinceCode, countryCode, postcode].every(hasValue);
|
|
11465
|
+
// Si al menos un campo de dirección está establecido, todos deben estarlo
|
|
11466
|
+
// Si no hay ningún campo de dirección establecido, no se aplica la validación
|
|
11467
|
+
if (anyFieldSet && !allFieldsSet) {
|
|
11468
|
+
return { direccionIncompleta: true };
|
|
11469
|
+
}
|
|
11470
|
+
return null;
|
|
11471
|
+
};
|
|
11472
|
+
}
|
|
11473
|
+
optionalMaxLengthValidator(max) {
|
|
11474
|
+
return (control) => {
|
|
11475
|
+
if (!control.value)
|
|
11476
|
+
return null;
|
|
11477
|
+
return control.value.length > max ? { maxLength: true } : null;
|
|
11478
|
+
};
|
|
11479
|
+
}
|
|
11480
|
+
normalizeRegisterData(data) {
|
|
11481
|
+
const normalizeString = (val) => val === undefined || val === null || val.toString().trim() === '' ? null : val.toString().trim();
|
|
11482
|
+
const normalizeBool = (val) => typeof val === 'boolean' ? val : val === 'true' ? true : val === 'false' ? false : null;
|
|
11483
|
+
return Object.assign(Object.assign({}, data), { birthday: normalizeString(data.birthday) || '', companyName: normalizeString(data.companyName), legalDenomination: normalizeString(data.legalDenomination), gender: normalizeString(data.gender), phoneNumber: normalizeString(data.phoneNumber), subscribedToNewsletter: normalizeBool(data.subscribedToNewsletter), documentType: normalizeString(data.documentType), documentNumber: normalizeString(data.documentNumber), comments: normalizeString(data.comments), contactFirstName: normalizeString(data.contactFirstName), contactLastName: normalizeString(data.contactLastName), contactCompanyPosition: normalizeString(data.contactCompanyPosition), contactEmail: normalizeString(data.contactEmail), contactDocumentType: normalizeString(data.contactDocumentType), contactDocumentNumber: normalizeString(data.contactDocumentNumber),
|
|
11484
|
+
// Dirección
|
|
11485
|
+
countryCode: normalizeString(data.countryCode), provinceCode: normalizeString(data.provinceCode), street: normalizeString(data.street), city: normalizeString(data.city), postcode: normalizeString(data.postcode) });
|
|
11379
11486
|
}
|
|
11380
11487
|
};
|
|
11381
11488
|
RegisterFormEcComponent.ctorParameters = () => [
|
|
@@ -11384,7 +11491,8 @@ RegisterFormEcComponent.ctorParameters = () => [
|
|
|
11384
11491
|
{ type: Router },
|
|
11385
11492
|
{ type: AnalyticsService },
|
|
11386
11493
|
{ type: FormBuilder },
|
|
11387
|
-
{ type: ChannelConfigService }
|
|
11494
|
+
{ type: ChannelConfigService },
|
|
11495
|
+
{ type: Constants }
|
|
11388
11496
|
];
|
|
11389
11497
|
__decorate$1n([
|
|
11390
11498
|
Input()
|
|
@@ -15888,21 +15996,6 @@ let SidebarEcComponent = class SidebarEcComponent {
|
|
|
15888
15996
|
this.hideTaxes = false;
|
|
15889
15997
|
this.creditAccountShowPrices = null;
|
|
15890
15998
|
this.showTaxLegend = false;
|
|
15891
|
-
this.actualizarCantidad = (item, cantidad, stock, id) => {
|
|
15892
|
-
if (id) {
|
|
15893
|
-
const elem = document.getElementById(id);
|
|
15894
|
-
elem.disabled = true;
|
|
15895
|
-
cantidad > 0 && cantidad <= stock
|
|
15896
|
-
? this.cartService.updateItemQuantity(item, cantidad)
|
|
15897
|
-
: this.toastrService.show('out-of-stock-actually');
|
|
15898
|
-
setTimeout(function () {
|
|
15899
|
-
elem.disabled = false;
|
|
15900
|
-
}, 1000);
|
|
15901
|
-
}
|
|
15902
|
-
else {
|
|
15903
|
-
cantidad > 0 && cantidad <= stock && this.cartService.updateItemQuantity(item, cantidad);
|
|
15904
|
-
}
|
|
15905
|
-
};
|
|
15906
15999
|
this.getVariants = product => {
|
|
15907
16000
|
let item = product.product;
|
|
15908
16001
|
if (item.variants && item.variants.length && item.variants[0].options && item.variants[0].options.length) {
|
|
@@ -15960,6 +16053,47 @@ let SidebarEcComponent = class SidebarEcComponent {
|
|
|
15960
16053
|
this.creditAccountShowPrices = showPrice;
|
|
15961
16054
|
});
|
|
15962
16055
|
}
|
|
16056
|
+
actualizarCantidad(item, cantidad, stock, id) {
|
|
16057
|
+
var _a;
|
|
16058
|
+
const multipleQuantity = ((_a = item.product) === null || _a === void 0 ? void 0 : _a.variants) && item.product.variants.length > 0 ? item.product.variants[0].multipleQuantity : 0;
|
|
16059
|
+
const step = multipleQuantity && multipleQuantity > 0 ? multipleQuantity : 1;
|
|
16060
|
+
let newQuantity;
|
|
16061
|
+
if (typeof cantidad === 'string') {
|
|
16062
|
+
newQuantity = parseInt(cantidad, 10);
|
|
16063
|
+
if (newQuantity % step !== 0) {
|
|
16064
|
+
this.toastrService.show('must-be-multiple', { quantity: step });
|
|
16065
|
+
newQuantity = Math.round(newQuantity / step) * step;
|
|
16066
|
+
}
|
|
16067
|
+
}
|
|
16068
|
+
else {
|
|
16069
|
+
newQuantity = cantidad;
|
|
16070
|
+
if (newQuantity % step !== 0) {
|
|
16071
|
+
newQuantity = Math.round(newQuantity / step) * step;
|
|
16072
|
+
}
|
|
16073
|
+
}
|
|
16074
|
+
if (id) {
|
|
16075
|
+
const elem = document.getElementById(id);
|
|
16076
|
+
if (elem) {
|
|
16077
|
+
elem.disabled = true;
|
|
16078
|
+
}
|
|
16079
|
+
if (newQuantity > 0 && newQuantity <= stock) {
|
|
16080
|
+
this.cartService.updateItemQuantity(item, newQuantity);
|
|
16081
|
+
}
|
|
16082
|
+
else {
|
|
16083
|
+
this.toastrService.show('out-of-stock-actually');
|
|
16084
|
+
}
|
|
16085
|
+
if (elem) {
|
|
16086
|
+
setTimeout(() => {
|
|
16087
|
+
elem.disabled = false;
|
|
16088
|
+
}, 1000);
|
|
16089
|
+
}
|
|
16090
|
+
}
|
|
16091
|
+
else {
|
|
16092
|
+
if (newQuantity > 0 && newQuantity <= stock) {
|
|
16093
|
+
this.cartService.updateItemQuantity(item, newQuantity);
|
|
16094
|
+
}
|
|
16095
|
+
}
|
|
16096
|
+
}
|
|
15963
16097
|
redirectDetailProduct(product) {
|
|
15964
16098
|
let variant = product.variants[0];
|
|
15965
16099
|
let path = '/product/';
|