mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-10-27 08:14:30 -04:00
fix: Misc Issues with Ingredient Parser (#6250)
This commit is contained in:
@@ -59,6 +59,7 @@
|
|||||||
class="mx-1"
|
class="mx-1"
|
||||||
:placeholder="$t('recipe.choose-unit')"
|
:placeholder="$t('recipe.choose-unit')"
|
||||||
clearable
|
clearable
|
||||||
|
:menu-props="{ attach: props.menuAttachTarget, maxHeight: '250px' }"
|
||||||
@keyup.enter="handleUnitEnter"
|
@keyup.enter="handleUnitEnter"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
@@ -115,6 +116,7 @@
|
|||||||
class="mx-1 py-0"
|
class="mx-1 py-0"
|
||||||
:placeholder="$t('recipe.choose-food')"
|
:placeholder="$t('recipe.choose-food')"
|
||||||
clearable
|
clearable
|
||||||
|
:menu-props="{ attach: props.menuAttachTarget, maxHeight: '250px' }"
|
||||||
@keyup.enter="handleFoodEnter"
|
@keyup.enter="handleFoodEnter"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
@@ -198,6 +200,10 @@ import type { RecipeIngredient } from "~/lib/api/types/recipe";
|
|||||||
const model = defineModel<RecipeIngredient>({ required: true });
|
const model = defineModel<RecipeIngredient>({ required: true });
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
menuAttachTarget: {
|
||||||
|
type: String,
|
||||||
|
default: "body",
|
||||||
|
},
|
||||||
unitError: {
|
unitError: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
:model-value="modelValue"
|
:model-value="modelValue"
|
||||||
:title="$t('recipe.parse-ingredients')"
|
:title="$t('recipe.parse-ingredients')"
|
||||||
:icon="$globals.icons.fileSign"
|
:icon="$globals.icons.fileSign"
|
||||||
|
disable-submit-on-enter
|
||||||
@update:model-value="emit('update:modelValue', $event)"
|
@update:model-value="emit('update:modelValue', $event)"
|
||||||
>
|
>
|
||||||
<v-container class="pa-2 ma-0" style="background-color: rgb(var(--v-theme-background));">
|
<v-container class="pa-2 ma-0" style="background-color: rgb(var(--v-theme-background));">
|
||||||
@@ -76,7 +77,11 @@
|
|||||||
{{ i18n.t("recipe.parser.missing-unit", { unit: currentMissingUnit }) }}
|
{{ i18n.t("recipe.parser.missing-unit", { unit: currentMissingUnit }) }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="currentMissingUnit && currentIng.ingredient.unit?.id"
|
v-if="
|
||||||
|
currentMissingUnit
|
||||||
|
&& currentIng.ingredient.unit?.id
|
||||||
|
&& currentMissingUnit.toLowerCase() != currentIng.ingredient.unit?.name.toLowerCase()
|
||||||
|
"
|
||||||
color="warning"
|
color="warning"
|
||||||
size="small"
|
size="small"
|
||||||
@click="addMissingUnitAsAlias"
|
@click="addMissingUnitAsAlias"
|
||||||
@@ -92,7 +97,11 @@
|
|||||||
{{ i18n.t("recipe.parser.missing-food", { food: currentMissingFood }) }}
|
{{ i18n.t("recipe.parser.missing-food", { food: currentMissingFood }) }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="currentMissingFood && currentIng.ingredient.food?.id"
|
v-if="
|
||||||
|
currentMissingFood
|
||||||
|
&& currentIng.ingredient.food?.id
|
||||||
|
&& currentMissingFood.toLowerCase() != currentIng.ingredient.food?.name.toLowerCase()
|
||||||
|
"
|
||||||
color="warning"
|
color="warning"
|
||||||
size="small"
|
size="small"
|
||||||
@click="addMissingFoodAsAlias"
|
@click="addMissingFoodAsAlias"
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
:max-width="maxWidth ?? undefined"
|
:max-width="maxWidth ?? undefined"
|
||||||
:content-class="top ? 'top-dialog' : undefined"
|
:content-class="top ? 'top-dialog' : undefined"
|
||||||
:fullscreen="$vuetify.display.xs"
|
:fullscreen="$vuetify.display.xs"
|
||||||
@keydown.enter="() => {
|
@keydown.enter="submitOnEnter"
|
||||||
emit('submit'); dialog = false;
|
|
||||||
}"
|
|
||||||
@click:outside="emit('cancel')"
|
@click:outside="emit('cancel')"
|
||||||
@keydown.esc="emit('cancel')"
|
@keydown.esc="emit('cancel')"
|
||||||
>
|
>
|
||||||
@@ -127,6 +125,7 @@ interface DialogProps {
|
|||||||
canDelete?: boolean;
|
canDelete?: boolean;
|
||||||
canConfirm?: boolean;
|
canConfirm?: boolean;
|
||||||
canSubmit?: boolean;
|
canSubmit?: boolean;
|
||||||
|
disableSubmitOnEnter?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DialogEmits {
|
interface DialogEmits {
|
||||||
@@ -150,6 +149,7 @@ const props = withDefaults(defineProps<DialogProps>(), {
|
|||||||
canDelete: false,
|
canDelete: false,
|
||||||
canConfirm: false,
|
canConfirm: false,
|
||||||
canSubmit: false,
|
canSubmit: false,
|
||||||
|
disableSubmitOnEnter: false,
|
||||||
});
|
});
|
||||||
const emit = defineEmits<DialogEmits>();
|
const emit = defineEmits<DialogEmits>();
|
||||||
|
|
||||||
@@ -181,6 +181,14 @@ function submitEvent() {
|
|||||||
submitted.value = true;
|
submitted.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function submitOnEnter() {
|
||||||
|
if (props.disableSubmitOnEnter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitEvent();
|
||||||
|
}
|
||||||
|
|
||||||
function deleteEvent() {
|
function deleteEvent() {
|
||||||
emit("delete");
|
emit("delete");
|
||||||
submitted.value = true;
|
submitted.value = true;
|
||||||
|
|||||||
@@ -29,20 +29,24 @@ export function useReadOnlyActions<T extends BoundT>(
|
|||||||
params.orderBy ??= "name";
|
params.orderBy ??= "name";
|
||||||
params.orderDirection ??= "asc";
|
params.orderDirection ??= "asc";
|
||||||
|
|
||||||
loading.value = true;
|
|
||||||
const allItems = useAsyncData(useAsyncKey(), async () => {
|
const allItems = useAsyncData(useAsyncKey(), async () => {
|
||||||
const { data } = await api.getAll(page, perPage, params);
|
loading.value = true;
|
||||||
loading.value = false;
|
try {
|
||||||
|
const { data } = await api.getAll(page, perPage, params);
|
||||||
|
|
||||||
if (data && allRef) {
|
if (data && allRef) {
|
||||||
allRef.value = data.items;
|
allRef.value = data.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
return data.items ?? [];
|
return data.items ?? [];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
finally {
|
||||||
return [];
|
loading.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,20 +88,24 @@ export function useStoreActions<T extends BoundT>(
|
|||||||
params.orderBy ??= "name";
|
params.orderBy ??= "name";
|
||||||
params.orderDirection ??= "asc";
|
params.orderDirection ??= "asc";
|
||||||
|
|
||||||
loading.value = true;
|
|
||||||
const allItems = useAsyncData(useAsyncKey(), async () => {
|
const allItems = useAsyncData(useAsyncKey(), async () => {
|
||||||
const { data } = await api.getAll(page, perPage, params);
|
loading.value = true;
|
||||||
loading.value = false;
|
try {
|
||||||
|
const { data } = await api.getAll(page, perPage, params);
|
||||||
|
|
||||||
if (data && allRef) {
|
if (data && allRef) {
|
||||||
allRef.value = data.items;
|
allRef.value = data.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
return data.items ?? [];
|
return data.items ?? [];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
finally {
|
||||||
return [];
|
loading.value = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const useReadOnlyStore = function <T extends BoundT>(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!loading.value && (!store.value || store.value.length === 0)) {
|
if (!loading.value && !store.value.length) {
|
||||||
const result = actions.getAll(1, -1, params);
|
const result = actions.getAll(1, -1, params);
|
||||||
store.value = result.value || [];
|
store.value = result.value || [];
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ export const useStore = function <T extends BoundT>(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!loading.value && (!store.value || store.value.length === 0)) {
|
if (!loading.value && !store.value.length) {
|
||||||
const result = actions.getAll(1, -1, params);
|
const result = actions.getAll(1, -1, params);
|
||||||
store.value = result.value || [];
|
store.value = result.value || [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user