ng-miam 10.5.5 → 10.5.8
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 +63 -33
- 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/basket-utils.service.js +10 -7
- package/esm2015/lib/_services/baskets.service.js +6 -4
- package/esm2015/lib/_services/context.service.js +2 -2
- package/esm2015/lib/_services/new-recipe-details.service.js +2 -2
- package/esm2015/lib/_services/replace-item.service.js +8 -8
- package/esm2015/lib/_web-components/basket-preview/basket-preview-product/basket-preview-product.component.js +2 -2
- package/esm2015/lib/_web-components/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.component.js +29 -6
- package/esm2015/lib/_web-components/recipe-pricing/recipe-pricing.component.js +12 -11
- package/esm2015/lib/environments/version.js +2 -2
- package/fesm2015/ng-miam.js +63 -34
- package/fesm2015/ng-miam.js.map +1 -1
- package/lib/_services/basket-utils.service.d.ts +1 -1
- package/lib/_services/basket-utils.service.d.ts.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/replace-item.service.d.ts.map +1 -1
- package/lib/_web-components/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.component.d.ts +4 -2
- package/lib/_web-components/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.component.d.ts.map +1 -1
- package/lib/_web-components/recipe-pricing/recipe-pricing.component.d.ts.map +1 -1
- package/lib/environments/version.d.ts +1 -1
- package/package.json +1 -1
package/bundles/ng-miam.umd.js
CHANGED
|
@@ -3452,7 +3452,7 @@
|
|
|
3452
3452
|
EventJourney["EMPTY"] = "";
|
|
3453
3453
|
})(EventJourney || (EventJourney = {}));
|
|
3454
3454
|
|
|
3455
|
-
var VERSION = "10.5.
|
|
3455
|
+
var VERSION = "10.5.8"; // 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
|
|
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,
|
|
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,
|
|
9864
|
+
ReplaceItemService.prototype.handleAddProductMode = function (item, eventTrace) {
|
|
9858
9865
|
var _this = this;
|
|
9859
9866
|
this.replaceItemLoading$.next(item);
|
|
9860
|
-
var newBasketEntry =
|
|
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
|
};
|
|
@@ -15106,19 +15112,21 @@
|
|
|
15106
15112
|
};
|
|
15107
15113
|
RecipePricingComponent.prototype.initPricingFromGuestsAndViewPort = function () {
|
|
15108
15114
|
var _this = this;
|
|
15109
|
-
// If the recipe is in basket, we ignore the change => pricing will be updated when the new basket preview is ready
|
|
15110
|
-
// After the shallow copy with events of the recipe, ngOnChanges is called again because the recipe object is different
|
|
15111
|
-
// So if changes contains only a recipe and no serves, we also avoid re-fetching
|
|
15112
15115
|
var wasInBasketBefore;
|
|
15116
|
+
var previousServes;
|
|
15113
15117
|
return rxjs.combineLatest([
|
|
15114
15118
|
this.posService.waitForPos,
|
|
15115
15119
|
this.isInView$,
|
|
15116
15120
|
this.guests$,
|
|
15117
15121
|
this.basketsService.recipeIsInBasket(this.recipeId)
|
|
15118
|
-
]).pipe(operators.skipWhile(function (results) { return !results[1]
|
|
15122
|
+
]).pipe(operators.skipWhile(function (results) { return !results[1]; })).subscribe(function (results) {
|
|
15119
15123
|
_this.pos = results[0];
|
|
15120
|
-
|
|
15121
|
-
|
|
15124
|
+
var inViewport = results[1];
|
|
15125
|
+
var serves = results[2];
|
|
15126
|
+
var recipeIsInBasket = results[3];
|
|
15127
|
+
var servesChanged = previousServes !== serves;
|
|
15128
|
+
// If the recipe is in basket, we ignore the change => pricing will be updated when the new basket preview is ready.
|
|
15129
|
+
if (!recipeIsInBasket && serves && (wasInBasketBefore !== false || servesChanged) && inViewport) {
|
|
15122
15130
|
_this.loading = true;
|
|
15123
15131
|
_this.cdr.detectChanges();
|
|
15124
15132
|
if (_this.onChangesSubscription) {
|
|
@@ -15126,7 +15134,8 @@
|
|
|
15126
15134
|
}
|
|
15127
15135
|
_this.onChangesSubscription = _this.fetchPricing().subscribe();
|
|
15128
15136
|
}
|
|
15129
|
-
wasInBasketBefore =
|
|
15137
|
+
wasInBasketBefore = recipeIsInBasket;
|
|
15138
|
+
previousServes = serves;
|
|
15130
15139
|
});
|
|
15131
15140
|
};
|
|
15132
15141
|
RecipePricingComponent.prototype.initPricingFromBasketChanges = function () {
|
|
@@ -15137,9 +15146,7 @@
|
|
|
15137
15146
|
_this.pos = results[0];
|
|
15138
15147
|
var recipeLine = results[1].find(function (l) { var _a, _b; return l.isRecipe && ((_a = l.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_b = _this.recipeId) === null || _b === void 0 ? void 0 : _b.toString()); });
|
|
15139
15148
|
if (!!recipeLine) {
|
|
15140
|
-
return _this.recipesService.getPricing(_this.recipeId, _this.pos.id, _this.serves).pipe(operators.switchMap(function (pricing) {
|
|
15141
|
-
return _this.extractPricing(recipeLine, pricing);
|
|
15142
|
-
}));
|
|
15149
|
+
return _this.recipesService.getPricing(_this.recipeId, _this.pos.id, _this.serves).pipe(operators.switchMap(function (pricing) { return _this.extractPricing(recipeLine, pricing); }));
|
|
15143
15150
|
}
|
|
15144
15151
|
return rxjs.of(null);
|
|
15145
15152
|
}));
|
|
@@ -16734,11 +16741,11 @@
|
|
|
16734
16741
|
_this.basketEntry.quantity = previousValue;
|
|
16735
16742
|
_this.cdr.detectChanges();
|
|
16736
16743
|
});
|
|
16737
|
-
this.basketSynchroService.addToActionList([updateQuantity]);
|
|
16738
16744
|
updateQuantity.onSuccess.pipe(operators.take(1)).subscribe(function () {
|
|
16739
16745
|
_this.basketEntry.quantity = newBasketEntry_1.quantity;
|
|
16740
16746
|
_this.subscriptions.push(_this.basketsService.reloadBasket().subscribe(function () { return _this.cdr.detectChanges(); }));
|
|
16741
16747
|
});
|
|
16748
|
+
this.basketSynchroService.addToActionList([updateQuantity]);
|
|
16742
16749
|
this.analyticsService.sendEvent('entry.change-quantity', this.path, {
|
|
16743
16750
|
entry_name: this.basketEntry.name,
|
|
16744
16751
|
item_id: this.basketEntry.selectedItem.id,
|
|
@@ -22140,16 +22147,26 @@
|
|
|
22140
22147
|
})();
|
|
22141
22148
|
|
|
22142
22149
|
var NoSupplierAddToCartCtaComponent = /** @class */ (function () {
|
|
22143
|
-
function NoSupplierAddToCartCtaComponent(noSupplierAddToCartCtaService, sanitizer, cdr) {
|
|
22150
|
+
function NoSupplierAddToCartCtaComponent(noSupplierAddToCartCtaService, sanitizer, cdr, element) {
|
|
22144
22151
|
this.noSupplierAddToCartCtaService = noSupplierAddToCartCtaService;
|
|
22145
22152
|
this.sanitizer = sanitizer;
|
|
22146
22153
|
this.cdr = cdr;
|
|
22154
|
+
this.element = element;
|
|
22147
22155
|
this.clicked = new i0.EventEmitter();
|
|
22148
22156
|
this.ctaHTML = null;
|
|
22149
22157
|
}
|
|
22150
22158
|
NoSupplierAddToCartCtaComponent.prototype.ngOnChanges = function (changes) {
|
|
22159
|
+
if (!this.recipeId) {
|
|
22160
|
+
return;
|
|
22161
|
+
}
|
|
22151
22162
|
var recipeId = String(this.recipeId);
|
|
22152
|
-
|
|
22163
|
+
var recipeIdChanged = !!changes.recipeId && recipeId !== this.loadedRecipeId;
|
|
22164
|
+
var guestsChanged = !!changes.guests &&
|
|
22165
|
+
changes.guests.previousValue !== changes.guests.currentValue;
|
|
22166
|
+
if (guestsChanged) {
|
|
22167
|
+
this.syncRenderedGuests();
|
|
22168
|
+
}
|
|
22169
|
+
if (!recipeIdChanged && !guestsChanged) {
|
|
22153
22170
|
return;
|
|
22154
22171
|
}
|
|
22155
22172
|
this.loadComponent(recipeId);
|
|
@@ -22162,15 +22179,28 @@
|
|
|
22162
22179
|
_this.ctaHTML = _this.sanitizer.bypassSecurityTrustHtml(html);
|
|
22163
22180
|
_this.clicked.emit();
|
|
22164
22181
|
_this.cdr.detectChanges();
|
|
22182
|
+
_this.syncRenderedGuests();
|
|
22165
22183
|
},
|
|
22166
22184
|
error: function (error) {
|
|
22167
22185
|
console.error('Error loading no-supplier-add-to-cart-cta component:', error);
|
|
22168
22186
|
}
|
|
22169
22187
|
});
|
|
22170
22188
|
};
|
|
22189
|
+
NoSupplierAddToCartCtaComponent.prototype.syncRenderedGuests = function () {
|
|
22190
|
+
var cta = this.element.nativeElement.querySelector('mealz-no-supplier-add-to-cart-cta');
|
|
22191
|
+
if (!cta) {
|
|
22192
|
+
return;
|
|
22193
|
+
}
|
|
22194
|
+
if (this.guests && this.guests > 0) {
|
|
22195
|
+
cta.setAttribute('guests', String(this.guests));
|
|
22196
|
+
}
|
|
22197
|
+
else {
|
|
22198
|
+
cta.removeAttribute('guests');
|
|
22199
|
+
}
|
|
22200
|
+
};
|
|
22171
22201
|
return NoSupplierAddToCartCtaComponent;
|
|
22172
22202
|
}());
|
|
22173
|
-
NoSupplierAddToCartCtaComponent.ɵfac = function NoSupplierAddToCartCtaComponent_Factory(t) { return new (t || NoSupplierAddToCartCtaComponent)(i0__namespace.ɵɵdirectiveInject(NoSupplierAddToCartCtaService), i0__namespace.ɵɵdirectiveInject(i2__namespace.DomSanitizer), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef)); };
|
|
22203
|
+
NoSupplierAddToCartCtaComponent.ɵfac = function NoSupplierAddToCartCtaComponent_Factory(t) { return new (t || NoSupplierAddToCartCtaComponent)(i0__namespace.ɵɵdirectiveInject(NoSupplierAddToCartCtaService), i0__namespace.ɵɵdirectiveInject(i2__namespace.DomSanitizer), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef)); };
|
|
22174
22204
|
NoSupplierAddToCartCtaComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: NoSupplierAddToCartCtaComponent, selectors: [["ng-miam-no-supplier-add-to-cart-cta"]], inputs: { recipeId: "recipeId", guests: "guests" }, outputs: { clicked: "clicked" }, features: [i0__namespace.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[3, "innerHTML"]], template: function NoSupplierAddToCartCtaComponent_Template(rf, ctx) {
|
|
22175
22205
|
if (rf & 1) {
|
|
22176
22206
|
i0__namespace.ɵɵelement(0, "div", 0);
|
|
@@ -22188,7 +22218,7 @@
|
|
|
22188
22218
|
encapsulation: i0.ViewEncapsulation.None,
|
|
22189
22219
|
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
22190
22220
|
}]
|
|
22191
|
-
}], function () { return [{ type: NoSupplierAddToCartCtaService }, { type: i2__namespace.DomSanitizer }, { type: i0__namespace.ChangeDetectorRef }]; }, { recipeId: [{
|
|
22221
|
+
}], function () { return [{ type: NoSupplierAddToCartCtaService }, { type: i2__namespace.DomSanitizer }, { type: i0__namespace.ChangeDetectorRef }, { type: i0__namespace.ElementRef }]; }, { recipeId: [{
|
|
22192
22222
|
type: i0.Input
|
|
22193
22223
|
}], guests: [{
|
|
22194
22224
|
type: i0.Input
|