ng-miam 6.3.10 → 6.3.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.
@@ -779,13 +779,14 @@
779
779
  // Unused in sdk at the moment but any client app can subscribe on it to know when a recipe has been added
780
780
  _this.recipeWasDeleted$ = new rxjs.BehaviorSubject([]);
781
781
  _this.recipesToRemove = new rxjs.BehaviorSubject([]);
782
+ _this.isRemovingRecipes = false;
782
783
  // Singleton instance of GroceriesList
783
784
  _this._list$ = new rxjs.BehaviorSubject(null);
784
785
  _this.saveOperationType = '';
785
786
  // Observe the fetching of the recipe so calls to list$ are delayed instead of calling refreshCurrentList dozens of times
786
787
  _this.listIsFetching = false;
787
788
  _this.register();
788
- _this.recipesToRemove.pipe(operators.skipWhile(function (toRemove) { return toRemove.length === 0; }), operators.debounceTime(1000), operators.switchMap(function () { return _this.emptyRecipesToRemove(); })).subscribe();
789
+ _this.recipesToRemove.pipe(operators.skipWhile(function (toRemove) { return toRemove.length === 0 || _this.isRemovingRecipes; }), operators.debounceTime(200), operators.tap(function () { return _this.emptyRecipesToRemove(); })).subscribe();
789
790
  return _this;
790
791
  }
791
792
  Object.defineProperty(GroceriesListsService.prototype, "list$", {
@@ -939,22 +940,24 @@
939
940
  };
940
941
  GroceriesListsService.prototype.emptyRecipesToRemove = function () {
941
942
  var _this = this;
943
+ this.isRemovingRecipes = true;
942
944
  var idsToRemove = this.recipesToRemove.value.map(function (i) { return i.id; });
943
945
  if (idsToRemove.length > 0) {
944
946
  var eventTrace_1 = this.recipesToRemove.value[0].eventTrace;
945
- return this.takeFirstList().pipe(operators.switchMap(function (list) {
947
+ this.takeFirstList().pipe(operators.switchMap(function (list) {
946
948
  if (list.attributes['recipes-infos']) {
947
949
  list.attributes['recipes-infos'] = list.attributes['recipes-infos'].filter(function (info) {
948
950
  return !idsToRemove.includes(info.id);
949
951
  });
950
952
  _this.analyticsService.sendEventWhenReady(_this.analyticsService.EVENT_RECIPE_REMOVE, eventTrace_1.originPath, eventTrace_1.props);
951
953
  _this.saveOperationType = 'REMOVE';
952
- return _this.saveList(list).pipe(operators.take(1), operators.tap(function () { return _this.recipesToRemove.next(_this.recipesToRemove.value.filter(function (i) { return !idsToRemove.includes(i.id); })); }));
954
+ return _this.saveList(list).pipe(operators.take(1));
953
955
  }
954
- return rxjs.of(null);
955
- }));
956
+ })).subscribe(function () {
957
+ _this.isRemovingRecipes = false;
958
+ _this.recipesToRemove.next(_this.recipesToRemove.value.filter(function (i) { return !idsToRemove.includes(i.id); }));
959
+ });
956
960
  }
957
- return rxjs.of(null);
958
961
  };
959
962
  /**
960
963
  * save() returns an object that isn't a resource so methods aren't attached, so we have to do a little trick
@@ -972,16 +975,19 @@
972
975
  delete (list.attributes['recipes-ids']);
973
976
  delete (list.relationships['groceries-entries']);
974
977
  return list.save({ include: ['groceries-entries'] }).pipe(operators.skipWhile(function (l) { return l.is_loading; }), operators.tap(function (l) {
975
- _this._list$.next(_this.afterSave(l));
976
- if (_this.saveOperationType === 'ADD') {
977
- _this.recipeWasAdded$.next(list.recipeInfos);
978
- }
979
- if (_this.saveOperationType === 'REMOVE') {
980
- _this.recipeWasDeleted$.next(list.recipeInfos);
981
- }
982
- _this.saveOperationType = '';
983
- if (openBasket) {
984
- window.open(_this.miamBasketURL + "/" + list.id, '_blank');
978
+ var _a;
979
+ if ((_a = l === null || l === void 0 ? void 0 : l.data) === null || _a === void 0 ? void 0 : _a.id) {
980
+ _this._list$.next(_this.afterSave(l));
981
+ if (_this.saveOperationType === 'ADD') {
982
+ _this.recipeWasAdded$.next(list.recipeInfos);
983
+ }
984
+ if (_this.saveOperationType === 'REMOVE') {
985
+ _this.recipeWasDeleted$.next(list.recipeInfos);
986
+ }
987
+ _this.saveOperationType = '';
988
+ if (openBasket) {
989
+ window.open(_this.miamBasketURL + "/" + list.id, '_blank');
990
+ }
985
991
  }
986
992
  }), operators.map(function (l) { return l.data; }));
987
993
  };
@@ -3588,19 +3594,22 @@
3588
3594
  this.suggestionsPrimaryButtonActions = { display: display, addToBasket: addToBasket };
3589
3595
  this.reloadAllRecipes();
3590
3596
  };
3591
- RecipesService.prototype.plan = function (budget, guests, recipesCount, includes, fields) {
3597
+ RecipesService.prototype.plan = function (budget, guests, recipesCount, includes, fields, in_basket) {
3592
3598
  var _this = this;
3593
3599
  if (includes === void 0) { includes = []; }
3594
3600
  if (fields === void 0) { fields = {}; }
3601
+ if (in_basket === void 0) { in_basket = undefined; }
3595
3602
  var plannerFields = '';
3596
3603
  Object.keys(fields).forEach(function (key) {
3597
3604
  var _a;
3598
3605
  plannerFields += "&fields[" + key + "]=" + ((_a = fields[key]) === null || _a === void 0 ? void 0 : _a.join(','));
3599
3606
  });
3600
3607
  var url = MIAM_API_HOST$3 + 'recipes/plan';
3608
+ url += "?budget=" + budget + "&filter[guests]=" + guests + "&recipes_count=" + recipesCount + "&filter[recipe_type_id]=main-dish";
3609
+ url += "&include=" + includes.join(',') + plannerFields + "&filter[recipe_type_id]=main-dish&filter[primary_completion_perc]=100,100";
3610
+ url += in_basket === undefined ? '' : "&filter[in_basket]=" + in_basket;
3601
3611
  return this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !(pos === null || pos === void 0 ? void 0 : pos.id); }), operators.take(1), operators.switchMap(function (pos) {
3602
- url += "?point_of_sale_id=" + pos.id + "&guests=" + guests + "&budget=" + budget + "&recipes_count=" + recipesCount;
3603
- url += "&include=" + includes.join(',') + plannerFields + "&filter[recipe_type_id]=main-dish";
3612
+ url += "&filter[point_of_sale_id]=" + pos.id;
3604
3613
  return _this.http.get(url, {}).pipe(operators.map(function (returnedRecipes) {
3605
3614
  var recipes = _this.newCollection();
3606
3615
  recipes.fill(returnedRecipes);
@@ -3608,10 +3617,14 @@
3608
3617
  }));
3609
3618
  }));
3610
3619
  };
3611
- RecipesService.prototype.maxPlannableRecipes = function (budget, guests) {
3620
+ RecipesService.prototype.maxPlannableRecipes = function (budget, guests, in_basket) {
3612
3621
  var _this = this;
3622
+ if (in_basket === void 0) { in_basket = undefined; }
3623
+ var url = MIAM_API_HOST$3 + 'recipes/plan_max_recipes';
3624
+ url += "?budget=" + budget + "&filter[guests]=" + guests + "&filter[recipe_type_id]=main-dish&filter[primary_completion_perc]=100,100";
3625
+ url += in_basket === undefined ? '' : "&filter[in_basket]=" + in_basket;
3613
3626
  return this.posService.pos$.pipe(operators.skipWhile(function (pos) { return !(pos === null || pos === void 0 ? void 0 : pos.id); }), operators.take(1), operators.switchMap(function (pos) {
3614
- return _this.http.get(MIAM_API_HOST$3 + ("recipes/plan_max_recipes?point_of_sale_id=" + pos.id + "&guests=" + guests + "&budget=" + budget + "&filter[recipe_type_id]=main-dish"), {}).pipe(operators.map(function (result) { return result.max_recipes; }));
3627
+ return _this.http.get(url += "&filter[point_of_sale_id]=" + pos.id, {}).pipe(operators.map(function (result) { return result.max_recipes; }));
3615
3628
  }));
3616
3629
  };
3617
3630
  // DEPRECATED / use TTL instead
@@ -13117,9 +13130,16 @@
13117
13130
  }
13118
13131
  };
13119
13132
  BasketPreviewDisabledComponent.prototype.ngOnChanges = function () {
13133
+ var _this = this;
13120
13134
  if (this.alwaysExpanded) {
13121
13135
  this.reduced = false;
13122
13136
  }
13137
+ Object.keys(this.loading).forEach(function (id) {
13138
+ var _a;
13139
+ if (((_a = _this.entries) === null || _a === void 0 ? void 0 : _a.filter(function (entry) { return entry.id === id; }).length) === 0) {
13140
+ delete _this.loading[id];
13141
+ }
13142
+ });
13123
13143
  };
13124
13144
  BasketPreviewDisabledComponent.prototype.onResize = function (event) {
13125
13145
  this.mobile = window.innerWidth <= MOBILE_BREAKPOINT;
@@ -25716,16 +25736,18 @@
25716
25736
  if (!this.form.value.guestsCount || !this.form.value.budget) {
25717
25737
  return rxjs.of(null);
25718
25738
  }
25719
- return this.recipesService.maxPlannableRecipes(this.form.value.budget, this.form.value.guestsCount).pipe(operators.tap(function (maxRecipes) {
25720
- var numbers = [];
25721
- for (var i = 1; i <= maxRecipes; i++) {
25722
- numbers.push(i);
25723
- }
25724
- _this.recipesNumbers = numbers;
25725
- if (_this.form.value.recipesCount > maxRecipes) {
25726
- _this.updateRecipesCount(0);
25727
- }
25728
- _this.noRecipesAvailable = maxRecipes < 1;
25739
+ return this.userService.isLogged$.asObservable().pipe(operators.take(2)).pipe(operators.switchMap(function (logged) {
25740
+ return _this.recipesService.maxPlannableRecipes(_this.form.value.budget, _this.form.value.guestsCount, logged ? false : undefined).pipe(operators.tap(function (maxRecipes) {
25741
+ var numbers = [];
25742
+ for (var i = 1; i <= maxRecipes; i++) {
25743
+ numbers.push(i);
25744
+ }
25745
+ _this.recipesNumbers = numbers;
25746
+ if (_this.form.value.recipesCount > maxRecipes) {
25747
+ _this.updateRecipesCount(maxRecipes);
25748
+ }
25749
+ _this.noRecipesAvailable = maxRecipes < 1;
25750
+ }));
25729
25751
  }));
25730
25752
  };
25731
25753
  MealsPlannerFormComponent.prototype.submit = function () {
@@ -26499,7 +26521,8 @@
26499
26521
  filters: {
26500
26522
  recipe_type_id: 'main-dish',
26501
26523
  price: "0," + this.remainingBudget,
26502
- in_basket: false
26524
+ in_basket: false,
26525
+ primary_completion_perc: '100,100'
26503
26526
  },
26504
26527
  title: ''
26505
26528
  };
@@ -26919,7 +26942,7 @@
26919
26942
  recipeSparseFields$5.recipes.push('ingredients');
26920
26943
  recipeSparseFields$5['ingredients'] = ['name', 'quantity', 'unit', 'active', 'forced-eans', 'picture-url', 'position'];
26921
26944
  }
26922
- this.recipesService.plan(inputs.budget, inputs.guestsCount, inputs.recipesCount, recipeIncludes$5, recipeSparseFields$5).pipe(operators.switchMap(function (recipes) {
26945
+ this.recipesService.plan(inputs.budget, inputs.guestsCount, inputs.recipesCount, recipeIncludes$5, recipeSparseFields$5, false).pipe(operators.switchMap(function (recipes) {
26923
26946
  _this.budgettedRecipes = []; // Refresh the result view
26924
26947
  _this.cdr.detectChanges();
26925
26948
  _this.budgettedRecipes = recipes.map(function (r) {
@@ -27462,7 +27485,7 @@
27462
27485
  request = request.clone({
27463
27486
  setHeaders: {
27464
27487
  'miam-origin': context.origin,
27465
- 'miam-front-version': '6.3.10',
27488
+ 'miam-front-version': '6.3.12',
27466
27489
  'miam-front-type': 'web',
27467
27490
  'miam-api-version': '4.7.0'
27468
27491
  }