ng-miam 10.5.5 → 10.5.7

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.
@@ -3452,7 +3452,7 @@
3452
3452
  EventJourney["EMPTY"] = "";
3453
3453
  })(EventJourney || (EventJourney = {}));
3454
3454
 
3455
- var VERSION = "10.5.5"; // TODO: replace by ##VERSION## and update it in the CI/CD
3455
+ var VERSION = "10.5.7"; // TODO: replace by ##VERSION## and update it in the CI/CD
3456
3456
 
3457
3457
  var ContextRegistryService = /** @class */ (function () {
3458
3458
  function ContextRegistryService() {
@@ -6516,11 +6516,12 @@
6516
6516
  }); });
6517
6517
  this.basketActionsQueue.next(toAdd);
6518
6518
  };
6519
- BasketsService.prototype.addItemToBasket = function (item, eventTrace, previousItem) {
6519
+ BasketsService.prototype.addItemToBasket = function (item, eventTrace, previousItem, forcedQuantity) {
6520
+ if (forcedQuantity === void 0) { forcedQuantity = 1; }
6520
6521
  var toAdd = this.basketActionsQueue.value;
6521
6522
  toAdd.push({
6522
6523
  type: BasketActionType.ADD_ITEM,
6523
- params: { item: item, eventTrace: eventTrace, previousItem: previousItem }
6524
+ params: { item: item, eventTrace: eventTrace, previousItem: previousItem, forcedQuantity: forcedQuantity }
6524
6525
  });
6525
6526
  this.basketActionsQueue.next(toAdd);
6526
6527
  };
@@ -6809,9 +6810,11 @@
6809
6810
  var _this = this;
6810
6811
  return this.waitForBasket.pipe(operators.switchMap(function (basket) {
6811
6812
  var requests = itemsToAdd.map(function (action) {
6813
+ var forcedQuantity = action.params.forcedQuantity || 1;
6812
6814
  var postUrl = environment$1.miamAPI + "/api/v1/baskets/" + basket.id + "/basket-entries/from-item" +
6813
6815
  ("?include=selected-item&selected_item_id=" + action.params.item.id) +
6814
- ("&name=" + action.params.item.attributes.name);
6816
+ ("&name=" + action.params.item.attributes.name) +
6817
+ ("&forced_quantity=" + forcedQuantity);
6815
6818
  return _this.http.post(encodeURI(postUrl.trim()), {});
6816
6819
  });
6817
6820
  // NOT WORKING AS ITEM AND NOT BASKET ENTRY
@@ -8454,13 +8457,16 @@
8454
8457
  var recipe = _a.recipe, basketEntries = _a.basketEntries;
8455
8458
  var filteredProducts = _this.buildRemoveProducts(recipe, basketEntries);
8456
8459
  var recipeRemoveActions = _this.buildRemoveActions(filteredProducts);
8457
- if (recipeRemoveActions.length !== 0) {
8458
- _this.basketSynchroService.addToActionList(recipeRemoveActions);
8459
- return recipeRemoveActions[recipeRemoveActions.length - 1].onSuccess.pipe(operators.take(1), operators.switchMap(function () { return _this.removeRecipeFromBasket(filteredProducts, recipeId, analyticsPath); }));
8460
- }
8461
- else {
8460
+ if (recipeRemoveActions.length === 0) {
8462
8461
  return _this.basketsService.removeRecipeById(recipeId, analyticsPath);
8463
8462
  }
8463
+ return new rxjs.Observable(function (observer) {
8464
+ var onSuccesses = rxjs.forkJoin(recipeRemoveActions.map(function (action) { return action.onSuccess.pipe(operators.take(1)); })).pipe(operators.switchMap(function () { return _this.removeRecipeFromBasket(filteredProducts, recipeId, analyticsPath); }));
8465
+ var onFailures = rxjs.merge.apply(void 0, __spread(recipeRemoveActions.map(function (action) { return action.onTimeout; }), recipeRemoveActions.map(function (action) { return action.onError; }))).pipe(operators.take(1), operators.switchMap(function () { return rxjs.throwError('Basket sync remove recipe failed'); }));
8466
+ var subscription = rxjs.merge(onSuccesses, onFailures).pipe(operators.take(1)).subscribe(observer);
8467
+ _this.basketSynchroService.addToActionList(recipeRemoveActions);
8468
+ return function () { return subscription.unsubscribe(); };
8469
+ });
8464
8470
  }));
8465
8471
  };
8466
8472
  BasketUtilsService.prototype.removeProduct = function (basketEntry, eventTrace) {
@@ -9770,7 +9776,7 @@
9770
9776
  .subscribe(function (action) {
9771
9777
  action.onSuccess.pipe(operators.take(1)).subscribe(function () {
9772
9778
  _this.recipeDetailsService.hasReplaced = true;
9773
- if (eventTrace && fromRecipeDetails) {
9779
+ if (eventTrace && fromRecipeDetails && !_this.addProductMode) {
9774
9780
  _this.sendReplaceEvent(searchString, eventTrace);
9775
9781
  }
9776
9782
  if (_this.addProductMode || !fromRecipeDetails) {
@@ -9788,6 +9794,7 @@
9788
9794
  });
9789
9795
  }
9790
9796
  });
9797
+ _this.basketSynchroService.addToActionList([action]);
9791
9798
  });
9792
9799
  };
9793
9800
  /**
@@ -9801,7 +9808,7 @@
9801
9808
  */
9802
9809
  ReplaceItemService.prototype.onSelectItem = function (item, searchString, eventTrace) {
9803
9810
  if (this.addProductMode) {
9804
- return this.handleAddProductMode(item, this.basketEntry, eventTrace);
9811
+ return this.handleAddProductMode(item, eventTrace);
9805
9812
  }
9806
9813
  return this.handleReplaceProductMode(item, this.basketEntry, this.ingredient, searchString, eventTrace, this.ignoreSelected);
9807
9814
  };
@@ -9854,10 +9861,12 @@
9854
9861
  * Handles any errors by rolling back the operation.
9855
9862
  * Adds the action to the synchronization service's action list for processing.
9856
9863
  */
9857
- ReplaceItemService.prototype.handleAddProductMode = function (item, basketEntry, eventTrace) {
9864
+ ReplaceItemService.prototype.handleAddProductMode = function (item, eventTrace) {
9858
9865
  var _this = this;
9859
9866
  this.replaceItemLoading$.next(item);
9860
- var newBasketEntry = deepCloneWithClass(basketEntry);
9867
+ var newBasketEntry = new BasketEntry();
9868
+ newBasketEntry.quantity = 1;
9869
+ newBasketEntry.quantityToAdd = 0;
9861
9870
  this.replaceRelationship(newBasketEntry, item);
9862
9871
  var addIngredientWithoutRecipe = new AddIngredientAction(newBasketEntry, { eventTrace: eventTrace, item: item }, this.basketsService, this.basketEntriesService);
9863
9872
  rxjs.merge(addIngredientWithoutRecipe.onTimeout, addIngredientWithoutRecipe.onError)
@@ -9865,7 +9874,6 @@
9865
9874
  .subscribe(function () {
9866
9875
  _this.rollbackReplace();
9867
9876
  });
9868
- this.basketSynchroService.addToActionList([addIngredientWithoutRecipe]);
9869
9877
  return rxjs.of(addIngredientWithoutRecipe);
9870
9878
  };
9871
9879
  /**
@@ -9922,7 +9930,6 @@
9922
9930
  rxjs.merge(addIngredientFromReplace.onTimeout, addIngredientFromReplace.onError).pipe(operators.take(1)).subscribe(function () {
9923
9931
  _this.rollbackReplace();
9924
9932
  });
9925
- _this.basketSynchroService.addToActionList([addIngredientFromReplace]);
9926
9933
  addIngredientFromReplace.onSuccess.pipe(operators.take(1)).subscribe(function () {
9927
9934
  _this.recipeDetailsService.updateIngredientFromBasketLoading = false;
9928
9935
  });
@@ -9998,7 +10005,6 @@
9998
10005
  searchString: searchString
9999
10006
  }, this.basketsService);
10000
10007
  this.handleAddIngredientActionErrors(addIngredient);
10001
- this.basketSynchroService.addToActionList([addIngredient]);
10002
10008
  // No need to send entry.added event, because it is done in the action
10003
10009
  return rxjs.of(addIngredient);
10004
10010
  };
@@ -10969,7 +10975,6 @@
10969
10975
  ingredientId: re.ingredientId,
10970
10976
  eventTrace: eventTrace
10971
10977
  }, _this.basketsService); });
10972
- _this.basketSynchroService.addToActionList(addRecipes);
10973
10978
  var onTimeouts = addRecipes.map(function (action) { return action.onTimeout; });
10974
10979
  var onErrors = addRecipes.map(function (action) { return action.onError; });
10975
10980
  var onSuccesses = addRecipes.map(function (action) { return action.onSuccess; });
@@ -10978,6 +10983,7 @@
10978
10983
  .subscribe({
10979
10984
  complete: function () { return _this.allIngredientsToBasketLoading$.next(false); }
10980
10985
  });
10986
+ _this.basketSynchroService.addToActionList(addRecipes);
10981
10987
  }
10982
10988
  else {
10983
10989
  _this.allIngredientsToBasketLoading$.next(false);
@@ -11808,11 +11814,11 @@
11808
11814
  _this.basketsService.resetBasket().subscribe();
11809
11815
  }
11810
11816
  var resetBasket = clonedEntriesToRemove.map(function (entry) { return new ResetBasketAction(entry, {}, _this.basketsService); });
11811
- _this.basketHandler.addToActionList(resetBasket);
11812
11817
  if (resetBasket.length > 0) {
11813
11818
  resetBasket[resetBasket.length - 1].onSuccess.pipe(operators.take(1)).subscribe(function () {
11814
11819
  _this.basketsService.resetBasket().subscribe();
11815
11820
  });
11821
+ _this.basketHandler.addToActionList(resetBasket);
11816
11822
  }
11817
11823
  });
11818
11824
  };
@@ -16734,11 +16740,11 @@
16734
16740
  _this.basketEntry.quantity = previousValue;
16735
16741
  _this.cdr.detectChanges();
16736
16742
  });
16737
- this.basketSynchroService.addToActionList([updateQuantity]);
16738
16743
  updateQuantity.onSuccess.pipe(operators.take(1)).subscribe(function () {
16739
16744
  _this.basketEntry.quantity = newBasketEntry_1.quantity;
16740
16745
  _this.subscriptions.push(_this.basketsService.reloadBasket().subscribe(function () { return _this.cdr.detectChanges(); }));
16741
16746
  });
16747
+ this.basketSynchroService.addToActionList([updateQuantity]);
16742
16748
  this.analyticsService.sendEvent('entry.change-quantity', this.path, {
16743
16749
  entry_name: this.basketEntry.name,
16744
16750
  item_id: this.basketEntry.selectedItem.id,