@etsoo/appscript 1.4.62 → 1.4.63
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.
|
@@ -295,12 +295,24 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
295
295
|
* @returns Result
|
|
296
296
|
*/
|
|
297
297
|
getItem(id: T['id']): T | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* Push item
|
|
300
|
+
* 推送项目
|
|
301
|
+
* @param data Item data
|
|
302
|
+
* @returns Added or not
|
|
303
|
+
*/
|
|
304
|
+
pushItem(data: T): boolean;
|
|
298
305
|
/**
|
|
299
306
|
* Reset currency and culture
|
|
300
307
|
* @param currency New currency
|
|
301
308
|
* @param culture New culture
|
|
302
309
|
*/
|
|
303
310
|
reset(currency: Currency, culture: string): void;
|
|
311
|
+
/**
|
|
312
|
+
* Remove item from the index
|
|
313
|
+
* @param index Item index
|
|
314
|
+
*/
|
|
315
|
+
removeItem(index: number): void;
|
|
304
316
|
/**
|
|
305
317
|
* Reset item
|
|
306
318
|
* @param item Shopping cart item
|
|
@@ -294,6 +294,21 @@ class ShoppingCart {
|
|
|
294
294
|
getItem(id) {
|
|
295
295
|
return this.items.find((item) => item.id === id);
|
|
296
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* Push item
|
|
299
|
+
* 推送项目
|
|
300
|
+
* @param data Item data
|
|
301
|
+
* @returns Added or not
|
|
302
|
+
*/
|
|
303
|
+
pushItem(data) {
|
|
304
|
+
if (this.items.some((item) => item.id === data.id)) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
this.addItem(data);
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
297
312
|
/**
|
|
298
313
|
* Reset currency and culture
|
|
299
314
|
* @param currency New currency
|
|
@@ -304,6 +319,14 @@ class ShoppingCart {
|
|
|
304
319
|
this.changeCurrency(currency);
|
|
305
320
|
this.changeCulture(culture);
|
|
306
321
|
}
|
|
322
|
+
/**
|
|
323
|
+
* Remove item from the index
|
|
324
|
+
* @param index Item index
|
|
325
|
+
*/
|
|
326
|
+
removeItem(index) {
|
|
327
|
+
const removedItems = this.items.splice(index, 1);
|
|
328
|
+
this.doChange('remove', removedItems);
|
|
329
|
+
}
|
|
307
330
|
/**
|
|
308
331
|
* Reset item
|
|
309
332
|
* @param item Shopping cart item
|
|
@@ -425,8 +448,7 @@ class ShoppingCart {
|
|
|
425
448
|
if (qty == null) {
|
|
426
449
|
// Remove the item
|
|
427
450
|
if (index !== -1) {
|
|
428
|
-
|
|
429
|
-
this.doChange('remove', removedItems);
|
|
451
|
+
this.removeItem(index);
|
|
430
452
|
}
|
|
431
453
|
}
|
|
432
454
|
else if (index === -1) {
|
|
@@ -295,12 +295,24 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
295
295
|
* @returns Result
|
|
296
296
|
*/
|
|
297
297
|
getItem(id: T['id']): T | undefined;
|
|
298
|
+
/**
|
|
299
|
+
* Push item
|
|
300
|
+
* 推送项目
|
|
301
|
+
* @param data Item data
|
|
302
|
+
* @returns Added or not
|
|
303
|
+
*/
|
|
304
|
+
pushItem(data: T): boolean;
|
|
298
305
|
/**
|
|
299
306
|
* Reset currency and culture
|
|
300
307
|
* @param currency New currency
|
|
301
308
|
* @param culture New culture
|
|
302
309
|
*/
|
|
303
310
|
reset(currency: Currency, culture: string): void;
|
|
311
|
+
/**
|
|
312
|
+
* Remove item from the index
|
|
313
|
+
* @param index Item index
|
|
314
|
+
*/
|
|
315
|
+
removeItem(index: number): void;
|
|
304
316
|
/**
|
|
305
317
|
* Reset item
|
|
306
318
|
* @param item Shopping cart item
|
|
@@ -291,6 +291,21 @@ export class ShoppingCart {
|
|
|
291
291
|
getItem(id) {
|
|
292
292
|
return this.items.find((item) => item.id === id);
|
|
293
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Push item
|
|
296
|
+
* 推送项目
|
|
297
|
+
* @param data Item data
|
|
298
|
+
* @returns Added or not
|
|
299
|
+
*/
|
|
300
|
+
pushItem(data) {
|
|
301
|
+
if (this.items.some((item) => item.id === data.id)) {
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
this.addItem(data);
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
294
309
|
/**
|
|
295
310
|
* Reset currency and culture
|
|
296
311
|
* @param currency New currency
|
|
@@ -301,6 +316,14 @@ export class ShoppingCart {
|
|
|
301
316
|
this.changeCurrency(currency);
|
|
302
317
|
this.changeCulture(culture);
|
|
303
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Remove item from the index
|
|
321
|
+
* @param index Item index
|
|
322
|
+
*/
|
|
323
|
+
removeItem(index) {
|
|
324
|
+
const removedItems = this.items.splice(index, 1);
|
|
325
|
+
this.doChange('remove', removedItems);
|
|
326
|
+
}
|
|
304
327
|
/**
|
|
305
328
|
* Reset item
|
|
306
329
|
* @param item Shopping cart item
|
|
@@ -422,8 +445,7 @@ export class ShoppingCart {
|
|
|
422
445
|
if (qty == null) {
|
|
423
446
|
// Remove the item
|
|
424
447
|
if (index !== -1) {
|
|
425
|
-
|
|
426
|
-
this.doChange('remove', removedItems);
|
|
448
|
+
this.removeItem(index);
|
|
427
449
|
}
|
|
428
450
|
}
|
|
429
451
|
else if (index === -1) {
|
package/package.json
CHANGED
|
@@ -503,6 +503,21 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
503
503
|
return this.items.find((item) => item.id === id);
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
+
/**
|
|
507
|
+
* Push item
|
|
508
|
+
* 推送项目
|
|
509
|
+
* @param data Item data
|
|
510
|
+
* @returns Added or not
|
|
511
|
+
*/
|
|
512
|
+
pushItem(data: T) {
|
|
513
|
+
if (this.items.some((item) => item.id === data.id)) {
|
|
514
|
+
return false;
|
|
515
|
+
} else {
|
|
516
|
+
this.addItem(data);
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
506
521
|
/**
|
|
507
522
|
* Reset currency and culture
|
|
508
523
|
* @param currency New currency
|
|
@@ -514,6 +529,15 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
514
529
|
this.changeCulture(culture);
|
|
515
530
|
}
|
|
516
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Remove item from the index
|
|
534
|
+
* @param index Item index
|
|
535
|
+
*/
|
|
536
|
+
removeItem(index: number) {
|
|
537
|
+
const removedItems = this.items.splice(index, 1);
|
|
538
|
+
this.doChange('remove', removedItems);
|
|
539
|
+
}
|
|
540
|
+
|
|
517
541
|
/**
|
|
518
542
|
* Reset item
|
|
519
543
|
* @param item Shopping cart item
|
|
@@ -655,8 +679,7 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
655
679
|
if (qty == null) {
|
|
656
680
|
// Remove the item
|
|
657
681
|
if (index !== -1) {
|
|
658
|
-
|
|
659
|
-
this.doChange('remove', removedItems);
|
|
682
|
+
this.removeItem(index);
|
|
660
683
|
}
|
|
661
684
|
} else if (index === -1) {
|
|
662
685
|
// New
|