diff --git a/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue b/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue index f643073ef196..d1e51bc33019 100644 --- a/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue +++ b/frontend/components/Domain/Recipe/RecipeIngredientEditor.vue @@ -32,6 +32,7 @@ { + const options = [ + { + text: i18n.tc("recipe.toggle-section"), + event: "toggle-section", + }, + ]; + + // FUTURE: add option to parse a single ingredient + // if (!value.food && !value.unit && value.note) { + // options.push({ + // text: "Parse Ingredient", + // event: "parse-ingredient", + // }); + // } + + if (props.value.originalText) { + options.push({ + text: i18n.tc("recipe.see-original-text"), + event: "toggle-original", + }); + } + + return options; + }); + + const btns = computed(() => { + const out = [ + { + icon: $globals.icons.dotsVertical, + text: i18n.tc("general.menu"), + event: "open", + children: contextMenuOptions.value, + }, + ]; + + if (listeners && listeners.delete) { + // @ts-expect-error - TODO: fix this + out.unshift({ + icon: $globals.icons.delete, + text: i18n.tc("general.delete"), + event: "delete", + }); + } + + return out; + }); // ================================================== // Foods @@ -209,32 +247,6 @@ export default defineComponent({ } } - const contextMenuOptions = computed(() => { - const options = [ - { - text: i18n.t("recipe.toggle-section") as string, - event: "toggle-section", - }, - ]; - - // FUTURE: add option to parse a single ingredient - // if (!value.food && !value.unit && value.note) { - // options.push({ - // text: "Parse Ingredient", - // event: "parse-ingredient", - // }); - // } - - if (props.value.originalText) { - options.push({ - text: i18n.t("recipe.see-original-text") as string, - event: "toggle-original", - }); - } - - return options; - }); - function quantityFilter(e: KeyboardEvent) { // if digit is pressed, add to quantity if (e.key === "-" || e.key === "+" || e.key === "e") { @@ -259,6 +271,7 @@ export default defineComponent({ unitSearch, validators, workingUnitData: unitsData.data, + btns, }; }, }); diff --git a/frontend/pages/recipe/_slug/ingredient-parser.vue b/frontend/pages/recipe/_slug/ingredient-parser.vue index cec981321d9f..01d8d26e193c 100644 --- a/frontend/pages/recipe/_slug/ingredient-parser.vue +++ b/frontend/pages/recipe/_slug/ingredient-parser.vue @@ -219,7 +219,8 @@ export default defineComponent({ return false; } if (units.value && unit?.name) { - return units.value.some((u) => u.name === unit.name); + const lower = unit.name.toLowerCase(); + return units.value.some((u) => u.name.toLowerCase() === lower); } return false; } @@ -229,7 +230,8 @@ export default defineComponent({ return false; } if (foodStore.foods.value && food?.name) { - return foodStore.foods.value.some((f) => f.name === food.name); + const lower = food.name.toLowerCase(); + return foodStore.foods.value.some((f) => f.name.toLowerCase() === lower); } return false; } @@ -246,7 +248,7 @@ export default defineComponent({ } // ========================================================= - // Save All Loginc + // Save All Logic async function saveAll() { let ingredients = parsedIng.value.map((ing) => { return { @@ -260,10 +262,12 @@ export default defineComponent({ return ing; } // Get food from foods - ing.food = foodStore.foods.value.find((f) => f.name === ing.food?.name); + const lowerFood = ing.food?.name?.toLowerCase(); + ing.food = foodStore.foods.value.find((f) => f.name.toLowerCase() === lowerFood); // Get unit from units - ing.unit = units.value.find((u) => u.name === ing.unit?.name); + const lowerUnit = ing.unit?.name?.toLowerCase(); + ing.unit = units.value.find((u) => u.name.toLowerCase() === lowerUnit); return ing; });