mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
update function signatures to ignore isFood/disableAmount
This commit is contained in:
parent
8d5f775f48
commit
9d998b8aaa
6 changed files with 13 additions and 27 deletions
|
@ -49,7 +49,7 @@ export default defineNuxtComponent({
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const parsedIng = computed(() => {
|
const parsedIng = computed(() => {
|
||||||
return useParsedIngredientText(props.ingredient, props.disableAmount, props.scale);
|
return useParsedIngredientText(props.ingredient, props.scale);
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
class="mb-n2 mt-n2"
|
class="mb-n2 mt-n2"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<RecipeIngredientHtml :markup="parseIngredientText(ing, recipe.settings.disableAmount)" />
|
<RecipeIngredientHtml :markup="parseIngredientText(ing)" />
|
||||||
</template>
|
</template>
|
||||||
</v-checkbox>
|
</v-checkbox>
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
class="mb-n2 mt-n2"
|
class="mb-n2 mt-n2"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<RecipeIngredientHtml :markup="parseIngredientText(ing, recipe.settings.disableAmount)" />
|
<RecipeIngredientHtml :markup="parseIngredientText(ing)" />
|
||||||
</template>
|
</template>
|
||||||
</v-checkbox>
|
</v-checkbox>
|
||||||
</template>
|
</template>
|
||||||
|
@ -554,7 +554,6 @@ function autoSetReferences() {
|
||||||
props.recipe.recipeIngredient,
|
props.recipe.recipeIngredient,
|
||||||
activeRefs.value,
|
activeRefs.value,
|
||||||
activeText.value,
|
activeText.value,
|
||||||
props.recipe.settings.disableAmount,
|
|
||||||
).forEach((ingredient: string) => activeRefs.value.push(ingredient));
|
).forEach((ingredient: string) => activeRefs.value.push(ingredient));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +575,7 @@ function getIngredientByRefId(refId: string | undefined) {
|
||||||
|
|
||||||
const ing = ingredientLookup.value[refId];
|
const ing = ingredientLookup.value[refId];
|
||||||
if (!ing) return "";
|
if (!ing) return "";
|
||||||
return parseIngredientText(ing, props.recipe.settings.disableAmount, props.scale);
|
return parseIngredientText(ing, props.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
|
@ -331,7 +331,7 @@ export default defineNuxtComponent({
|
||||||
});
|
});
|
||||||
|
|
||||||
function parseText(ingredient: RecipeIngredient) {
|
function parseText(ingredient: RecipeIngredient) {
|
||||||
return parseIngredientText(ingredient, props.recipe.settings?.disableAmount || false, props.scale);
|
return parseIngredientText(ingredient, props.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -19,10 +19,7 @@
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
<div :class="listItem.checked ? 'strike-through' : ''">
|
<div :class="listItem.checked ? 'strike-through' : ''">
|
||||||
<RecipeIngredientListItem
|
<RecipeIngredientListItem :ingredient="listItem" />
|
||||||
:ingredient="listItem"
|
|
||||||
:disable-amount="!(listItem.isFood || listItem.quantity !== 1)"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</v-checkbox>
|
</v-checkbox>
|
||||||
|
@ -170,7 +167,6 @@
|
||||||
@save="save"
|
@save="save"
|
||||||
@cancel="toggleEdit(false)"
|
@cancel="toggleEdit(false)"
|
||||||
@delete="$emit('delete')"
|
@delete="$emit('delete')"
|
||||||
@toggle-foods="localListItem.isFood = !localListItem.isFood"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -18,8 +18,8 @@ function removeStartingPunctuation(word: string): string {
|
||||||
return word.replace(punctuationAtBeginning, "");
|
return word.replace(punctuationAtBeginning, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function ingredientMatchesWord(ingredient: RecipeIngredient, word: string, recipeIngredientAmountsDisabled: boolean) {
|
function ingredientMatchesWord(ingredient: RecipeIngredient, word: string) {
|
||||||
const searchText = parseIngredientText(ingredient, recipeIngredientAmountsDisabled);
|
const searchText = parseIngredientText(ingredient);
|
||||||
return searchText.toLowerCase().includes(word.toLowerCase());
|
return searchText.toLowerCase().includes(word.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ function isBlackListedWord(word: string) {
|
||||||
return blackListedText.includes(word) || word.match(blackListedRegexMatch);
|
return blackListedText.includes(word) || word.match(blackListedRegexMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useExtractIngredientReferences(recipeIngredients: RecipeIngredient[], activeRefs: string[], text: string, recipeIngredientAmountsDisabled: boolean): Set<string> {
|
export function useExtractIngredientReferences(recipeIngredients: RecipeIngredient[], activeRefs: string[], text: string): Set<string> {
|
||||||
const availableIngredients = recipeIngredients
|
const availableIngredients = recipeIngredients
|
||||||
.filter(ingredient => ingredient.referenceId !== undefined)
|
.filter(ingredient => ingredient.referenceId !== undefined)
|
||||||
.filter(ingredient => !activeRefs.includes(ingredient.referenceId as string));
|
.filter(ingredient => !activeRefs.includes(ingredient.referenceId as string));
|
||||||
|
@ -50,7 +50,7 @@ export function useExtractIngredientReferences(recipeIngredients: RecipeIngredie
|
||||||
.map(normalize)
|
.map(normalize)
|
||||||
.filter(word => word.length > 2)
|
.filter(word => word.length > 2)
|
||||||
.filter(word => !isBlackListedWord(word))
|
.filter(word => !isBlackListedWord(word))
|
||||||
.flatMap(word => availableIngredients.filter(ingredient => ingredientMatchesWord(ingredient, word, recipeIngredientAmountsDisabled)))
|
.flatMap(word => availableIngredients.filter(ingredient => ingredientMatchesWord(ingredient, word)))
|
||||||
.map(ingredient => ingredient.referenceId as string);
|
.map(ingredient => ingredient.referenceId as string);
|
||||||
// deduplicate
|
// deduplicate
|
||||||
|
|
||||||
|
|
|
@ -36,16 +36,7 @@ function useUnitName(unit: CreateIngredientUnit | IngredientUnit | undefined, us
|
||||||
return returnVal;
|
return returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useParsedIngredientText(ingredient: RecipeIngredient, disableAmount: boolean, scale = 1, includeFormating = true) {
|
export function useParsedIngredientText(ingredient: RecipeIngredient, scale = 1, includeFormating = true) {
|
||||||
if (disableAmount) {
|
|
||||||
return {
|
|
||||||
name: ingredient.note ? sanitizeIngredientHTML(ingredient.note) : undefined,
|
|
||||||
quantity: undefined,
|
|
||||||
unit: undefined,
|
|
||||||
note: undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const { quantity, food, unit, note } = ingredient;
|
const { quantity, food, unit, note } = ingredient;
|
||||||
const usePluralUnit = quantity !== undefined && ((quantity || 0) * scale > 1 || (quantity || 0) * scale === 0);
|
const usePluralUnit = quantity !== undefined && ((quantity || 0) * scale > 1 || (quantity || 0) * scale === 0);
|
||||||
const usePluralFood = (!quantity) || quantity * scale > 1;
|
const usePluralFood = (!quantity) || quantity * scale > 1;
|
||||||
|
@ -82,8 +73,8 @@ export function useParsedIngredientText(ingredient: RecipeIngredient, disableAmo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseIngredientText(ingredient: RecipeIngredient, disableAmount: boolean, scale = 1, includeFormating = true): string {
|
export function parseIngredientText(ingredient: RecipeIngredient, scale = 1, includeFormating = true): string {
|
||||||
const { quantity, unit, name, note } = useParsedIngredientText(ingredient, disableAmount, scale, includeFormating);
|
const { quantity, unit, name, note } = useParsedIngredientText(ingredient, scale, includeFormating);
|
||||||
|
|
||||||
const text = `${quantity || ""} ${unit || ""} ${name || ""} ${note || ""}`.replace(/ {2,}/g, " ").trim();
|
const text = `${quantity || ""} ${unit || ""} ${name || ""} ${note || ""}`.replace(/ {2,}/g, " ").trim();
|
||||||
return sanitizeIngredientHTML(text);
|
return sanitizeIngredientHTML(text);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue