diff --git a/vue/src/components/IngredientComponent.vue b/vue/src/components/IngredientComponent.vue
index 0b10d4d3d..3c531e77a 100644
--- a/vue/src/components/IngredientComponent.vue
+++ b/vue/src/components/IngredientComponent.vue
@@ -7,124 +7,65 @@
- |
+ |
|
-
+
|
{{ ingredient.unit.name }}
|
- {{ ingredient.food.name }}
+ {{ ingredient.food.name }}
{{ ingredient.food.name }}
|
-
+ |
- {{ ingredient.note }}
+ {{
+ ingredient.note
+ }}
+
|
-
-
-
-
-
-
-
- |
diff --git a/vue/src/components/IngredientsCard.vue b/vue/src/components/IngredientsCard.vue
index 279745724..e8591e63b 100644
--- a/vue/src/components/IngredientsCard.vue
+++ b/vue/src/components/IngredientsCard.vue
@@ -6,42 +6,27 @@
{{ $t("Ingredients") }}
-
-
-
-
-
-
-
-
+
-
+
|
{{ s.name }}
|
@@ -80,7 +65,6 @@ export default {
servings: {type: Number, default: 1},
detailed: {type: Boolean, default: true},
header: {type: Boolean, default: false},
- add_shopping_mode: {type: Boolean, default: false},
recipe_list: {type: Number, default: undefined},
},
data() {
@@ -108,145 +92,13 @@ export default {
},
},
watch: {
- ShoppingRecipes: function (newVal, oldVal) {
- if (newVal.length === 0 || this.add_shopping_mode) {
- this.selected_shoppingrecipe = this.recipe_list
- } else if (newVal.length === 1) {
- this.selected_shoppingrecipe = newVal[0].value
- }
- },
- selected_shoppingrecipe: function (newVal, oldVal) {
- this.update_shopping = this.shopping_list.filter((x) => x.list_recipe === newVal).map((x) => x.ingredient)
- this.$emit("change-servings", this.ShoppingRecipes.filter((x) => x.value === this.selected_shoppingrecipe)[0].servings)
- },
+
},
mounted() {
- if (this.add_shopping_mode) {
- this.show_shopping = true
- this.getShopping(false)
- }
+
},
methods: {
- getShopping: function (toggle_shopping = true) {
- if (toggle_shopping) {
- this.show_shopping = !this.show_shopping
- }
- if (this.show_shopping) {
- let ingredient_list = this.steps
- .map((x) => x.ingredients)
- .flat()
- .filter((x) => (x.food !== null && x.food !== undefined))
- .map((x) => x.food.id)
-
- let params = {
- id: ingredient_list,
- checked: "false",
- }
- this.genericAPI(this.Models.SHOPPING_LIST, this.Actions.LIST, params).then((result) => {
- this.shopping_list = result.data
-
- if (this.add_shopping_mode) {
- if (this.recipe_list) {
- this.$emit(
- "starting-cart",
- this.shopping_list.filter((x) => x.list_recipe === this.recipe_list).map((x) => x.ingredient)
- )
- } else {
- this.$emit(
- "starting-cart",
- this.steps
- .map((x) => x.ingredients)
- .flat()
- .filter((x) => x?.food?.food_onhand == false && x?.food?.ignore_shopping == false)
- .map((x) => x.id)
- )
- }
- }
- })
- }
- },
- saveShopping: function (del_shopping = false) {
- let servings = this.servings
- if (del_shopping) {
- servings = -1
- }
- let params = {
- id: this.recipe,
- list_recipe: this.selected_shoppingrecipe,
- ingredients: this.update_shopping,
- servings: servings,
- }
- this.genericAPI(this.Models.RECIPE, this.Actions.SHOPPING, params)
- .then((result) => {
- if (del_shopping) {
- StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_DELETE)
- } else if (this.selected_shoppingrecipe) {
- StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_UPDATE)
- } else {
- StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_CREATE)
- }
- })
- .catch((err) => {
- if (del_shopping) {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
- } else if (this.selected_shoppingrecipe) {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_UPDATE, err)
- } else {
- StandardToasts.makeStandardToast(this, StandardToasts.FAIL_CREATE, err)
- }
- this.$emit("shopping-failed")
- })
- },
- addShopping: function (e) {
- // ALERT: this will all break if ingredients are re-used between recipes
- if (e.add) {
- this.update_shopping.push(e.item.id)
- this.shopping_list.push({
- id: Math.random(),
- amount: e.item.amount,
- ingredient: e.item.id,
- food: e.item.food,
- list_recipe: this.selected_shoppingrecipe,
- })
- } else {
- this.update_shopping = [...this.update_shopping.filter((x) => x !== e.item.id)]
- this.shopping_list = [...this.shopping_list.filter((x) => !(x.ingredient === e.item.id && x.list_recipe === this.selected_shoppingrecipe))]
- }
- if (this.add_shopping_mode) {
- this.$emit("add-to-shopping", e)
- }
- },
- prepareIngredient: function (i) {
- let shopping = this.shopping_list.filter((x) => x.ingredient === i.id)
- let selected_list = this.shopping_list.filter((x) => x.list_recipe === this.selected_shoppingrecipe && x.ingredient === i.id)
- // checked = in the selected shopping list OR if in shoppping mode without a selected recipe, the default value true unless it is ignored or onhand
- let checked = selected_list.length > 0 || (this.add_shopping_mode && !this.selected_shoppingrecipe && !i?.food?.ignore_recipe && !i?.food?.food_onhand)
-
- let shopping_status = false // not in shopping list
- if (shopping.length > 0) {
- if (selected_list.length > 0) {
- shopping_status = true // in shopping list for *this* recipe
- } else {
- shopping_status = null // in shopping list but not *this* recipe
- }
- }
-
- return {
- ...i,
- shop: checked,
- shopping_status: shopping_status, // possible values: true, false, null
- category: i.food?.supermarket_category?.name,
- shopping_list: shopping.map((x) => {
- return {
- mealplan: x?.recipe_mealplan?.name,
- amount: x.amount,
- food: x.food?.name,
- unit: x.unit?.name,
- }
- }),
- }
- },
},
}