ng-easycommerce 0.0.679 → 0.0.680
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 +3 -0
- package/bundles/ng-easycommerce.umd.js +162 -27
- 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/cart-ec/cart-ec.component.js +26 -1
- package/esm2015/lib/ec-component/multiple-items-to-cart-ec/multiple-items-to-cart-ec.component.js +75 -2
- package/esm2015/lib/ec-component/product-detail-ec/product-detail-ec.component.js +65 -28
- package/esm5/lib/ec-component/cart-ec/cart-ec.component.js +26 -1
- package/esm5/lib/ec-component/multiple-items-to-cart-ec/multiple-items-to-cart-ec.component.js +75 -2
- package/esm5/lib/ec-component/product-detail-ec/product-detail-ec.component.js +64 -27
- package/fesm2015/ng-easycommerce.js +163 -28
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +162 -27
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/ec-component/cart-ec/cart-ec.component.d.ts +2 -0
- package/lib/ec-component/multiple-items-to-cart-ec/multiple-items-to-cart-ec.component.d.ts +8 -0
- package/lib/ec-component/product-detail-ec/product-detail-ec.component.d.ts +15 -4
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
|
@@ -6521,6 +6521,31 @@ let CartEcComponent = class CartEcComponent extends ComponentHelper {
|
|
|
6521
6521
|
this.cartLoading = false;
|
|
6522
6522
|
this.enableFieldNotesInArticleFile = false;
|
|
6523
6523
|
this.toDecimal = (amount) => this.consts.toDecimal(amount);
|
|
6524
|
+
this.cartItemPlus = (item) => {
|
|
6525
|
+
var _a, _b;
|
|
6526
|
+
const multipleQty = ((_a = item.product.variants[0]) === null || _a === void 0 ? void 0 : _a.multipleQuantity) || 0;
|
|
6527
|
+
const step = multipleQty || 1;
|
|
6528
|
+
const stock = (_b = item.product.variants[0]) === null || _b === void 0 ? void 0 : _b.stock;
|
|
6529
|
+
const current = item.quantity;
|
|
6530
|
+
const next = step > 1 && current % step !== 0
|
|
6531
|
+
? Math.ceil(current / step) * step
|
|
6532
|
+
: current + step;
|
|
6533
|
+
this.actualizarCantidad(item, next, stock, 'cartPlus');
|
|
6534
|
+
};
|
|
6535
|
+
this.cartItemLess = (item) => {
|
|
6536
|
+
var _a, _b, _c;
|
|
6537
|
+
const multipleQty = ((_a = item.product.variants[0]) === null || _a === void 0 ? void 0 : _a.multipleQuantity) || 0;
|
|
6538
|
+
const minimumQty = ((_b = item.product.variants[0]) === null || _b === void 0 ? void 0 : _b.minimumItemsQuantity) || 0;
|
|
6539
|
+
const step = multipleQty || 1;
|
|
6540
|
+
const floor = minimumQty || step;
|
|
6541
|
+
const current = item.quantity;
|
|
6542
|
+
const next = step > 1 && current % step !== 0
|
|
6543
|
+
? Math.floor(current / step) * step
|
|
6544
|
+
: current - step;
|
|
6545
|
+
if (next >= floor) {
|
|
6546
|
+
this.actualizarCantidad(item, next, (_c = item.product.variants[0]) === null || _c === void 0 ? void 0 : _c.stock, 'cartLess');
|
|
6547
|
+
}
|
|
6548
|
+
};
|
|
6524
6549
|
this.redirectRegister = () => this.router.navigateByUrl(`/auth/login`);
|
|
6525
6550
|
this.getVariants = product => {
|
|
6526
6551
|
let item = product.product;
|
|
@@ -11725,6 +11750,9 @@ let ProductDetailEcComponent = class ProductDetailEcComponent extends ComponentH
|
|
|
11725
11750
|
this.hidePrices = false;
|
|
11726
11751
|
this.creditAccountShowPrices = null;
|
|
11727
11752
|
this.enableFieldNotesInArticleFile = false;
|
|
11753
|
+
this.quantityError = '';
|
|
11754
|
+
this.minimumItemsQty = null;
|
|
11755
|
+
this.multipleQty = null;
|
|
11728
11756
|
this.addToCart = () => {
|
|
11729
11757
|
var _a;
|
|
11730
11758
|
const note = ((_a = this.comments) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
@@ -11740,20 +11768,23 @@ let ProductDetailEcComponent = class ProductDetailEcComponent extends ComponentH
|
|
|
11740
11768
|
};
|
|
11741
11769
|
/**
|
|
11742
11770
|
* @description actualiza la variable quantity sumandole 'x' contenido.
|
|
11771
|
+
* Si hay un multipleQuantity configurado, hace snap al siguiente múltiplo válido
|
|
11772
|
+
* cuando la cantidad actual ya es inválida.
|
|
11743
11773
|
* @param stock número máximo disponible en stock.
|
|
11744
|
-
* @param changeAmount cantidad que se quiere sumar.
|
|
11745
|
-
* @param forceMultiple si es true, obliga a que el resultado sea múltiplo de changeAmount.
|
|
11774
|
+
* @param changeAmount cantidad que se quiere sumar (ignorado si multipleQty está seteado).
|
|
11775
|
+
* @param forceMultiple legacy — si es true, obliga a que el resultado sea múltiplo de changeAmount.
|
|
11746
11776
|
*/
|
|
11747
11777
|
this.plus = (stock, changeAmount = 1, forceMultiple = false) => {
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11778
|
+
const step = this.multipleQty || changeAmount;
|
|
11779
|
+
const currentQuantity = Number(this.quantity);
|
|
11780
|
+
let newQuantity;
|
|
11781
|
+
if (step > 1) {
|
|
11782
|
+
newQuantity = currentQuantity % step !== 0
|
|
11783
|
+
? Math.ceil(currentQuantity / step) * step
|
|
11784
|
+
: currentQuantity + step;
|
|
11785
|
+
}
|
|
11786
|
+
else {
|
|
11787
|
+
newQuantity = currentQuantity + step;
|
|
11757
11788
|
}
|
|
11758
11789
|
if (!stock || newQuantity <= stock) {
|
|
11759
11790
|
this.quantity = newQuantity;
|
|
@@ -11761,32 +11792,56 @@ let ProductDetailEcComponent = class ProductDetailEcComponent extends ComponentH
|
|
|
11761
11792
|
else {
|
|
11762
11793
|
this.toastrService.show('out-of-stock-actually');
|
|
11763
11794
|
}
|
|
11795
|
+
this.validateDetail();
|
|
11764
11796
|
};
|
|
11765
11797
|
/**
|
|
11766
11798
|
* @description actualiza la variable quantity restandole 'x' contenido.
|
|
11767
|
-
*
|
|
11768
|
-
*
|
|
11799
|
+
* Si hay un multipleQuantity configurado, hace snap al múltiplo válido inferior
|
|
11800
|
+
* cuando la cantidad actual ya es inválida.
|
|
11801
|
+
* @param changeAmount cantidad que se quiere restar (ignorado si multipleQty está seteado).
|
|
11802
|
+
* @param minimum cantidad mínima permitida (ignorado si minimumItemsQty está seteado).
|
|
11803
|
+
* @param forceMultiple legacy — si es true, obliga a que el resultado sea múltiplo de changeAmount.
|
|
11769
11804
|
*/
|
|
11770
11805
|
this.less = (changeAmount = 1, minimum = 1, forceMultiple = false) => {
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
}
|
|
11779
|
-
if (newQuantity < changeAmount) {
|
|
11780
|
-
newQuantity = changeAmount;
|
|
11781
|
-
}
|
|
11806
|
+
const step = this.multipleQty || changeAmount;
|
|
11807
|
+
const floor = this.minimumItemsQty || (step > 1 ? step : minimum);
|
|
11808
|
+
let newQuantity;
|
|
11809
|
+
if (step > 1) {
|
|
11810
|
+
newQuantity = this.quantity % step !== 0
|
|
11811
|
+
? Math.floor(this.quantity / step) * step
|
|
11812
|
+
: this.quantity - step;
|
|
11782
11813
|
}
|
|
11783
|
-
|
|
11784
|
-
this.quantity
|
|
11814
|
+
else {
|
|
11815
|
+
newQuantity = this.quantity - step;
|
|
11816
|
+
}
|
|
11817
|
+
this.quantity = newQuantity >= floor ? newQuantity : floor;
|
|
11818
|
+
this.validateDetail();
|
|
11819
|
+
};
|
|
11820
|
+
this.onQuantityInput = (value) => {
|
|
11821
|
+
const parsed = parseInt(value, 10);
|
|
11822
|
+
if (!isNaN(parsed)) {
|
|
11823
|
+
this.quantity = parsed;
|
|
11824
|
+
this.validateDetail();
|
|
11825
|
+
}
|
|
11826
|
+
};
|
|
11827
|
+
this.validateDetail = () => {
|
|
11828
|
+
if (this.minimumItemsQty && this.quantity < this.minimumItemsQty) {
|
|
11829
|
+
this.quantityError = 'La cantidad debe ser al menos ' + this.minimumItemsQty;
|
|
11830
|
+
}
|
|
11831
|
+
else if (this.multipleQty && this.quantity % this.multipleQty !== 0) {
|
|
11832
|
+
this.quantityError = 'La cantidad debe ser m\u00faltiplo de ' + this.multipleQty;
|
|
11785
11833
|
}
|
|
11786
11834
|
else {
|
|
11787
|
-
this.
|
|
11835
|
+
this.quantityError = '';
|
|
11788
11836
|
}
|
|
11789
11837
|
};
|
|
11838
|
+
this.isQuantityValidDetail = () => {
|
|
11839
|
+
if (this.minimumItemsQty && this.quantity < this.minimumItemsQty)
|
|
11840
|
+
return false;
|
|
11841
|
+
if (this.multipleQty && this.quantity % this.multipleQty !== 0)
|
|
11842
|
+
return false;
|
|
11843
|
+
return true;
|
|
11844
|
+
};
|
|
11790
11845
|
this.showContact = () => this.show = true;
|
|
11791
11846
|
this.hideContact = () => this.show = false;
|
|
11792
11847
|
this.thereIsMoreInfo = (product) => {
|
|
@@ -11865,6 +11920,13 @@ let ProductDetailEcComponent = class ProductDetailEcComponent extends ComponentH
|
|
|
11865
11920
|
});
|
|
11866
11921
|
this.comments = (_l = (_k = match) === null || _k === void 0 ? void 0 : _k.comments, (_l !== null && _l !== void 0 ? _l : ''));
|
|
11867
11922
|
});
|
|
11923
|
+
this.productService.asociatedData$.subscribe(ad => {
|
|
11924
|
+
var _a, _b;
|
|
11925
|
+
this.minimumItemsQty = ((_a = ad) === null || _a === void 0 ? void 0 : _a.minimumItemsQuantity) || null;
|
|
11926
|
+
this.multipleQty = ((_b = ad) === null || _b === void 0 ? void 0 : _b.multipleQuantity) || null;
|
|
11927
|
+
this.quantity = this.minimumItemsQty || this.multipleQty || 1;
|
|
11928
|
+
this.quantityError = '';
|
|
11929
|
+
});
|
|
11868
11930
|
}
|
|
11869
11931
|
ngOnDestroy() {
|
|
11870
11932
|
var _a;
|
|
@@ -16306,7 +16368,77 @@ let MultipleItemsToCartEcComponent = class MultipleItemsToCartEcComponent extend
|
|
|
16306
16368
|
this.totalItems = new EventEmitter();
|
|
16307
16369
|
this.total = 0;
|
|
16308
16370
|
this.countItems = 0;
|
|
16371
|
+
this.quantity = 1;
|
|
16372
|
+
this.spanInfo = '';
|
|
16309
16373
|
this.optionsProductForVariant = () => this.product.productWithUniqueVariant;
|
|
16374
|
+
this.plus = (product, stock, multipleQuantity) => {
|
|
16375
|
+
if (multipleQuantity && multipleQuantity > 0) {
|
|
16376
|
+
const next = this.quantity % multipleQuantity !== 0
|
|
16377
|
+
? Math.ceil(this.quantity / multipleQuantity) * multipleQuantity
|
|
16378
|
+
: this.quantity + multipleQuantity;
|
|
16379
|
+
stock ? (next <= stock ? this.quantity = next : this.toastService.show('out-of-stock-actually'))
|
|
16380
|
+
: this.quantity = next;
|
|
16381
|
+
this.setQuantity(this.quantity, product);
|
|
16382
|
+
this.validateQuantity(this.quantity, product);
|
|
16383
|
+
}
|
|
16384
|
+
else {
|
|
16385
|
+
stock ? (this.quantity < stock ? this.quantity = this.quantity + 1 : this.toastService.show('out-of-stock-actually'))
|
|
16386
|
+
: this.quantity = this.quantity + 1;
|
|
16387
|
+
this.setQuantity(this.quantity, product);
|
|
16388
|
+
}
|
|
16389
|
+
};
|
|
16390
|
+
this.less = (product, multipleQuantity, minimumItemsQuantity) => {
|
|
16391
|
+
if (multipleQuantity && multipleQuantity >= 0) {
|
|
16392
|
+
const minimum = minimumItemsQuantity || multipleQuantity;
|
|
16393
|
+
const next = this.quantity % multipleQuantity !== 0
|
|
16394
|
+
? Math.floor(this.quantity / multipleQuantity) * multipleQuantity
|
|
16395
|
+
: this.quantity - multipleQuantity;
|
|
16396
|
+
if (next >= minimum) {
|
|
16397
|
+
this.quantity = next;
|
|
16398
|
+
}
|
|
16399
|
+
this.setQuantity(this.quantity, product);
|
|
16400
|
+
this.validateQuantity(this.quantity, product);
|
|
16401
|
+
}
|
|
16402
|
+
else {
|
|
16403
|
+
this.quantity > 0 ? this.quantity = this.quantity - 1 : null;
|
|
16404
|
+
this.setQuantity(this.quantity, product);
|
|
16405
|
+
}
|
|
16406
|
+
};
|
|
16407
|
+
this.isQuantityValid = (quantity, item) => {
|
|
16408
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16409
|
+
const minimumItemsQuantity = (_c = (_b = (_a = item) === null || _a === void 0 ? void 0 : _a.variants) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.minimumItemsQuantity;
|
|
16410
|
+
const multipleQuantity = (_f = (_e = (_d = item) === null || _d === void 0 ? void 0 : _d.variants) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.multipleQuantity;
|
|
16411
|
+
if (minimumItemsQuantity && quantity < minimumItemsQuantity)
|
|
16412
|
+
return false;
|
|
16413
|
+
if (multipleQuantity && quantity % multipleQuantity !== 0)
|
|
16414
|
+
return false;
|
|
16415
|
+
return true;
|
|
16416
|
+
};
|
|
16417
|
+
this.validateQuantity = (quantity, item) => {
|
|
16418
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16419
|
+
const minimumItemsQuantity = (_c = (_b = (_a = item) === null || _a === void 0 ? void 0 : _a.variants) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.minimumItemsQuantity;
|
|
16420
|
+
const multipleQuantity = (_f = (_e = (_d = item) === null || _d === void 0 ? void 0 : _d.variants) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.multipleQuantity;
|
|
16421
|
+
this.spanInfo = '';
|
|
16422
|
+
if (minimumItemsQuantity && quantity < minimumItemsQuantity) {
|
|
16423
|
+
this.spanInfo = 'La cantidad debe ser al menos ' + minimumItemsQuantity;
|
|
16424
|
+
}
|
|
16425
|
+
else if (multipleQuantity && quantity % multipleQuantity !== 0) {
|
|
16426
|
+
this.spanInfo = 'La cantidad debe ser m\u00faltiplo de ' + multipleQuantity;
|
|
16427
|
+
}
|
|
16428
|
+
};
|
|
16429
|
+
this.buildButtons = (asociatedData) => {
|
|
16430
|
+
const maximumNumberOfButtons = 6;
|
|
16431
|
+
if (asociatedData.multipleQuantity) {
|
|
16432
|
+
const maximum = asociatedData.maximumItemsQuantity || asociatedData.stock;
|
|
16433
|
+
const minimum = asociatedData.minimumItemsQuantity || asociatedData.multipleQuantity;
|
|
16434
|
+
const buttons = [];
|
|
16435
|
+
for (let i = minimum; i <= maximum; i = i + asociatedData.multipleQuantity) {
|
|
16436
|
+
buttons.push(i);
|
|
16437
|
+
}
|
|
16438
|
+
return buttons.length > maximumNumberOfButtons ? buttons.slice(0, maximumNumberOfButtons) : buttons;
|
|
16439
|
+
}
|
|
16440
|
+
return undefined;
|
|
16441
|
+
};
|
|
16310
16442
|
this.setQuantity = (value, product) => {
|
|
16311
16443
|
let quantity = Number(value) > product.currentOption.stock ? product.currentOption.stock : Number(value);
|
|
16312
16444
|
product.productToCartItem = {
|
|
@@ -16341,8 +16473,11 @@ let MultipleItemsToCartEcComponent = class MultipleItemsToCartEcComponent extend
|
|
|
16341
16473
|
this.ecOnConstruct();
|
|
16342
16474
|
}
|
|
16343
16475
|
ngOnInit() {
|
|
16344
|
-
var _a;
|
|
16476
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
16345
16477
|
this.product.productWithUniqueVariant = (_a = this.productService) === null || _a === void 0 ? void 0 : _a.getProductWithUniqueVariant(this.product, this.getObjectParamsWithVariant());
|
|
16478
|
+
const minQty = (_d = (_c = (_b = this.product) === null || _b === void 0 ? void 0 : _b.variants) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.minimumItemsQuantity;
|
|
16479
|
+
const multipleQty = (_g = (_f = (_e = this.product) === null || _e === void 0 ? void 0 : _e.variants) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.multipleQuantity;
|
|
16480
|
+
this.quantity = minQty || multipleQty || 1;
|
|
16346
16481
|
this.ecOnInit();
|
|
16347
16482
|
}
|
|
16348
16483
|
};
|