ng-miam 9.0.11 → 9.0.12
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/bundles/ng-miam.umd.js +18 -15
- package/bundles/ng-miam.umd.js.map +1 -1
- package/bundles/ng-miam.umd.min.js +1 -1
- package/bundles/ng-miam.umd.min.js.map +1 -1
- package/esm2015/lib/_services/baskets.service.js +3 -9
- package/esm2015/lib/_services/recipe-details.service.js +15 -5
- package/esm2015/lib/_web-components/basket-preview/replace-item/replace-item.component.js +3 -3
- package/fesm2015/ng-miam.js +18 -14
- package/fesm2015/ng-miam.js.map +1 -1
- package/lib/_services/baskets.service.d.ts +1 -1
- package/lib/_services/baskets.service.d.ts.map +1 -1
- package/lib/_services/recipe-details.service.d.ts.map +1 -1
- package/package.json +1 -1
package/bundles/ng-miam.umd.js
CHANGED
|
@@ -5709,20 +5709,13 @@
|
|
|
5709
5709
|
* Fetches the BasketEntry for an ingredient if it exists
|
|
5710
5710
|
* Returns a fake BasketEntry with id = -1 if it doesn't exist
|
|
5711
5711
|
*/
|
|
5712
|
-
BasketsService.prototype.basketEntryFromIngredient = function (ingredientId, guests,
|
|
5712
|
+
BasketsService.prototype.basketEntryFromIngredient = function (ingredientId, guests, selectedItemId) {
|
|
5713
5713
|
var _this = this;
|
|
5714
|
-
if (onlyQuantity === void 0) { onlyQuantity = false; }
|
|
5715
5714
|
return this.waitForBasket.pipe(operators.switchMap(function (basket) {
|
|
5716
|
-
var url = environment$1.miamAPI + "/api/v1/baskets/" + basket.id + "/basket-entries/from-ingredient?ingredient_id=" + ingredientId + "&guests=" + guests;
|
|
5715
|
+
var url = environment$1.miamAPI + "/api/v1/baskets/" + basket.id + "/basket-entries/from-ingredient?ingredient_id=" + ingredientId + "&guests=" + guests + "&include=selected-item";
|
|
5717
5716
|
if (selectedItemId) {
|
|
5718
5717
|
url += "&selected_item_id=" + selectedItemId;
|
|
5719
5718
|
}
|
|
5720
|
-
if (onlyQuantity) {
|
|
5721
|
-
url += '&fields[basket-entries]=quantity,quantity-to-add';
|
|
5722
|
-
}
|
|
5723
|
-
else {
|
|
5724
|
-
url += '&include=selected-item';
|
|
5725
|
-
}
|
|
5726
5719
|
return _this.http.get(url);
|
|
5727
5720
|
}), operators.skipWhile(function (result) { return !result; }), operators.map(function (res) {
|
|
5728
5721
|
var entry = _this.basketEntriesService.new();
|
|
@@ -10032,14 +10025,24 @@
|
|
|
10032
10025
|
if (!fromInit) {
|
|
10033
10026
|
this.ingredientToBasketLoading = true;
|
|
10034
10027
|
}
|
|
10035
|
-
var basketEntries$ = this.recipe.ingredients.map(function (ingredient) { return _this.basketsService.basketEntryFromIngredient(ingredient.id, _this.recipe.modifiedGuests
|
|
10028
|
+
var basketEntries$ = this.recipe.ingredients.map(function (ingredient) { return _this.basketsService.basketEntryFromIngredient(ingredient.id, _this.recipe.modifiedGuests).pipe(operators.map(function (basketEntry) { return ({ ingredient: ingredient, basketEntry: basketEntry }); })); });
|
|
10036
10029
|
return rxjs.forkJoin(basketEntries$).pipe(operators.switchMap(function (basketEntriesResult) {
|
|
10037
|
-
|
|
10030
|
+
var updateProducts = function () {
|
|
10038
10031
|
_this.products = basketEntriesResult;
|
|
10039
|
-
|
|
10032
|
+
_this.setProductsByCategory();
|
|
10033
|
+
};
|
|
10034
|
+
if (fromInit) {
|
|
10035
|
+
updateProducts();
|
|
10036
|
+
return rxjs.of([]);
|
|
10040
10037
|
}
|
|
10041
10038
|
else {
|
|
10042
|
-
_this.
|
|
10039
|
+
var hasSelectedItemChanged = basketEntriesResult.some(function (incomingProduct) { return _this.products.some(function (p) { return p.basketEntry.attributes['selected-item-id'] ===
|
|
10040
|
+
incomingProduct.basketEntry.attributes['selected-item-id']; }); });
|
|
10041
|
+
// If at least one selected item has changed, we need to refresh categories
|
|
10042
|
+
// and prices entirely instead of only updating quantities
|
|
10043
|
+
hasSelectedItemChanged
|
|
10044
|
+
? updateProducts()
|
|
10045
|
+
: _this.updatePriceOnGuestChange(basketEntriesResult);
|
|
10043
10046
|
return rxjs.of(_this.products);
|
|
10044
10047
|
}
|
|
10045
10048
|
}), operators.switchMap(function () { return rxjs.of(_this.products); }));
|
|
@@ -17011,7 +17014,7 @@
|
|
|
17011
17014
|
_this.rollbackReplace();
|
|
17012
17015
|
});
|
|
17013
17016
|
this.basketSynchroService.addToActionList([removeIngredient]);
|
|
17014
|
-
this.subscriptions.push(this.basketsService.basketEntryFromIngredient(this.ingredient.id, +this.recipe.modifiedGuests,
|
|
17017
|
+
this.subscriptions.push(this.basketsService.basketEntryFromIngredient(this.ingredient.id, +this.recipe.modifiedGuests, item.id).pipe(operators.switchMap(function (newEntry) {
|
|
17015
17018
|
var newBasketEntry = deepCloneWithClass(_this.basketEntry);
|
|
17016
17019
|
newBasketEntry.quantityToAdd = newEntry.quantityToAdd;
|
|
17017
17020
|
_this.replaceRelationship(newBasketEntry, item);
|
|
@@ -17039,7 +17042,7 @@
|
|
|
17039
17042
|
};
|
|
17040
17043
|
ReplaceItemComponent.prototype.addToBasket = function (item) {
|
|
17041
17044
|
var _this = this;
|
|
17042
|
-
this.subscriptions.push(this.recipeDetailsService.canAddProductToBasket(this.getAddIngredientMethod(), this.eventTrace).pipe(operators.filter(function (passed) { return passed; }), operators.switchMap(function () { return _this.basketsService.basketEntryFromIngredient(_this.ingredient.id, +_this.recipe.modifiedGuests,
|
|
17045
|
+
this.subscriptions.push(this.recipeDetailsService.canAddProductToBasket(this.getAddIngredientMethod(), this.eventTrace).pipe(operators.filter(function (passed) { return passed; }), operators.switchMap(function () { return _this.basketsService.basketEntryFromIngredient(_this.ingredient.id, +_this.recipe.modifiedGuests, item.id); })).subscribe(function (newEntry) { return _this.handleAddToBasketResponse(newEntry); }));
|
|
17043
17046
|
this.cdr.detectChanges();
|
|
17044
17047
|
};
|
|
17045
17048
|
ReplaceItemComponent.prototype.getAddIngredientMethod = function () {
|