ng-miam 10.5.7 → 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.
@@ -3452,7 +3452,7 @@
3452
3452
  EventJourney["EMPTY"] = "";
3453
3453
  })(EventJourney || (EventJourney = {}));
3454
3454
 
3455
- var VERSION = "10.5.7"; // TODO: replace by ##VERSION## and update it in the CI/CD
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() {
@@ -15112,19 +15112,21 @@
15112
15112
  };
15113
15113
  RecipePricingComponent.prototype.initPricingFromGuestsAndViewPort = function () {
15114
15114
  var _this = this;
15115
- // If the recipe is in basket, we ignore the change => pricing will be updated when the new basket preview is ready
15116
- // After the shallow copy with events of the recipe, ngOnChanges is called again because the recipe object is different
15117
- // So if changes contains only a recipe and no serves, we also avoid re-fetching
15118
15115
  var wasInBasketBefore;
15116
+ var previousServes;
15119
15117
  return rxjs.combineLatest([
15120
15118
  this.posService.waitForPos,
15121
15119
  this.isInView$,
15122
15120
  this.guests$,
15123
15121
  this.basketsService.recipeIsInBasket(this.recipeId)
15124
- ]).pipe(operators.skipWhile(function (results) { return !results[1] || !results[3]; })).subscribe(function (results) {
15122
+ ]).pipe(operators.skipWhile(function (results) { return !results[1]; })).subscribe(function (results) {
15125
15123
  _this.pos = results[0];
15126
- // fetch the price if the recipe isn't in the basket and if it was last time we check or on startup
15127
- if (!results[3] && wasInBasketBefore !== false && _this.inViewport) {
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) {
15128
15130
  _this.loading = true;
15129
15131
  _this.cdr.detectChanges();
15130
15132
  if (_this.onChangesSubscription) {
@@ -15132,7 +15134,8 @@
15132
15134
  }
15133
15135
  _this.onChangesSubscription = _this.fetchPricing().subscribe();
15134
15136
  }
15135
- wasInBasketBefore = results[3];
15137
+ wasInBasketBefore = recipeIsInBasket;
15138
+ previousServes = serves;
15136
15139
  });
15137
15140
  };
15138
15141
  RecipePricingComponent.prototype.initPricingFromBasketChanges = function () {
@@ -15143,9 +15146,7 @@
15143
15146
  _this.pos = results[0];
15144
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()); });
15145
15148
  if (!!recipeLine) {
15146
- return _this.recipesService.getPricing(_this.recipeId, _this.pos.id, _this.serves).pipe(operators.switchMap(function (pricing) {
15147
- return _this.extractPricing(recipeLine, pricing);
15148
- }));
15149
+ return _this.recipesService.getPricing(_this.recipeId, _this.pos.id, _this.serves).pipe(operators.switchMap(function (pricing) { return _this.extractPricing(recipeLine, pricing); }));
15149
15150
  }
15150
15151
  return rxjs.of(null);
15151
15152
  }));
@@ -22146,16 +22147,26 @@
22146
22147
  })();
22147
22148
 
22148
22149
  var NoSupplierAddToCartCtaComponent = /** @class */ (function () {
22149
- function NoSupplierAddToCartCtaComponent(noSupplierAddToCartCtaService, sanitizer, cdr) {
22150
+ function NoSupplierAddToCartCtaComponent(noSupplierAddToCartCtaService, sanitizer, cdr, element) {
22150
22151
  this.noSupplierAddToCartCtaService = noSupplierAddToCartCtaService;
22151
22152
  this.sanitizer = sanitizer;
22152
22153
  this.cdr = cdr;
22154
+ this.element = element;
22153
22155
  this.clicked = new i0.EventEmitter();
22154
22156
  this.ctaHTML = null;
22155
22157
  }
22156
22158
  NoSupplierAddToCartCtaComponent.prototype.ngOnChanges = function (changes) {
22159
+ if (!this.recipeId) {
22160
+ return;
22161
+ }
22157
22162
  var recipeId = String(this.recipeId);
22158
- if (!changes.recipeId || !this.recipeId || recipeId === this.loadedRecipeId) {
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) {
22159
22170
  return;
22160
22171
  }
22161
22172
  this.loadComponent(recipeId);
@@ -22168,15 +22179,28 @@
22168
22179
  _this.ctaHTML = _this.sanitizer.bypassSecurityTrustHtml(html);
22169
22180
  _this.clicked.emit();
22170
22181
  _this.cdr.detectChanges();
22182
+ _this.syncRenderedGuests();
22171
22183
  },
22172
22184
  error: function (error) {
22173
22185
  console.error('Error loading no-supplier-add-to-cart-cta component:', error);
22174
22186
  }
22175
22187
  });
22176
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
+ };
22177
22201
  return NoSupplierAddToCartCtaComponent;
22178
22202
  }());
22179
- 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)); };
22180
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) {
22181
22205
  if (rf & 1) {
22182
22206
  i0__namespace.ɵɵelement(0, "div", 0);
@@ -22194,7 +22218,7 @@
22194
22218
  encapsulation: i0.ViewEncapsulation.None,
22195
22219
  changeDetection: i0.ChangeDetectionStrategy.OnPush
22196
22220
  }]
22197
- }], 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: [{
22198
22222
  type: i0.Input
22199
22223
  }], guests: [{
22200
22224
  type: i0.Input