1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-03 04:25:24 +02:00

feat: Migrate to Nuxt 3 framework (#5184)

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
This commit is contained in:
Hoa (Kyle) Trinh 2025-06-20 00:09:12 +07:00 committed by GitHub
parent 89ab7fac25
commit c24d532608
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
403 changed files with 23959 additions and 19557 deletions

View file

@ -3,10 +3,9 @@
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import CookbookPage from "@/components/Domain/Cookbook/CookbookPage.vue";
export default defineComponent({
export default defineNuxtComponent({
components: { CookbookPage },
})
});
</script>

View file

@ -0,0 +1,260 @@
<template>
<div>
<!-- Create Dialog -->
<BaseDialog
v-if="createTarget"
v-model="dialogStates.create"
width="100%"
max-width="1100px"
:icon="$globals.icons.pages"
:title="$t('cookbook.create-a-cookbook')"
:submit-icon="$globals.icons.save"
:submit-text="$t('general.save')"
:submit-disabled="!createTarget.queryFilterString"
can-submit
@submit="actions.updateOne(createTarget)"
@cancel="deleteCreateTarget()"
>
<v-card-text>
<CookbookEditor :key="createTargetKey" v-model="createTarget" :actions="actions" />
</v-card-text>
</BaseDialog>
<!-- Delete Dialog -->
<BaseDialog
v-model="dialogStates.delete"
:title="$t('general.delete-with-name', { name: $t('cookbook.cookbook') })"
:icon="$globals.icons.alertCircle"
color="error"
can-confirm
@confirm="deleteCookbook()"
>
<v-card-text>
<p>{{ $t("general.confirm-delete-generic-with-name", { name: $t("cookbook.cookbook") }) }}</p>
<p v-if="deleteTarget" class="mt-4 ml-4">
{{ deleteTarget.name }}
</p>
</v-card-text>
</BaseDialog>
<!-- Cookbook Page -->
<!-- Page Title -->
<v-container class="px-12" max-width="1000">
<BasePageTitle divider>
<template #header>
<v-img width="100%" max-height="100" max-width="100" :src="require('~/static/svgs/manage-cookbooks.svg')" />
</template>
<template #title>
{{ $t("cookbook.cookbooks") }}
</template>
{{ $t("cookbook.description") }}
</BasePageTitle>
<div class="my-6">
<v-checkbox
v-model="cookbookPreferences.hideOtherHouseholds"
:label="$t('cookbook.hide-cookbooks-from-other-households')"
hide-details
color="primary"
/>
<div class="ml-10 mt-n3">
<p class="text-subtitle-2 my-0 py-0">
{{ $t("cookbook.hide-cookbooks-from-other-households-description") }}
</p>
</div>
</div>
<!-- Create New -->
<BaseButton create @click="createCookbook" />
<!-- Cookbook List -->
<v-expansion-panels class="mt-2">
<VueDraggable
v-model="myCookbooks"
handle=".handle"
:delay="250"
:delay-on-touch-only="true"
style="width: 100%"
@end="actions.updateOrder(myCookbooks)"
>
<v-expansion-panel
v-for="(cookbook, index) in myCookbooks"
:key="cookbook.id"
class="my-2 left-border rounded"
>
<v-expansion-panel-title disable-icon-rotate class="text-h6 opacity-80">
<div class="d-flex align-center">
<v-icon size="large" start>
{{ $globals.icons.pages }}
</v-icon>
{{ cookbook.name }}
</div>
<template #actions>
<div class="d-flex align-center">
<v-btn icon variant="text" class="ml-2">
<v-icon>
{{ $globals.icons.edit }}
</v-icon>
</v-btn>
<v-icon class="handle" :size="40">
{{ $globals.icons.arrowUpDown }}
</v-icon>
</div>
</template>
</v-expansion-panel-title>
<v-expansion-panel-text>
<CookbookEditor
v-model="myCookbooks[index]"
:actions="actions"
:collapsable="false"
@delete="deleteEventHandler"
/>
<v-card-actions>
<v-spacer />
<BaseButtonGroup
:buttons="[
{
icon: $globals.icons.delete,
text: $t('general.delete'),
event: 'delete',
},
{
icon: $globals.icons.save,
text: $t('general.save'),
event: 'save',
disabled: !cookbook.queryFilterString,
},
]"
@delete="deleteEventHandler(myCookbooks[index])"
@save="actions.updateOne(myCookbooks[index])"
/>
</v-card-actions>
</v-expansion-panel-text>
</v-expansion-panel>
</VueDraggable>
</v-expansion-panels>
</v-container>
</div>
</template>
<script lang="ts">
import { VueDraggable } from "vue-draggable-plus";
import { useCookbooks } from "@/composables/use-group-cookbooks";
import { useHouseholdSelf } from "@/composables/use-households";
import CookbookEditor from "~/components/Domain/Cookbook/CookbookEditor.vue";
import type { ReadCookBook } from "~/lib/api/types/cookbook";
import { useCookbookPreferences } from "~/composables/use-users/preferences";
export default defineNuxtComponent({
components: { CookbookEditor, VueDraggable },
middleware: ["sidebase-auth", "group-only"],
setup() {
const dialogStates = reactive({
create: false,
delete: false,
});
const i18n = useI18n();
// Set page title
useSeoMeta({
title: i18n.t("cookbook.cookbooks"),
});
const $auth = useMealieAuth();
const { cookbooks: allCookbooks, actions } = useCookbooks();
// Make a local reactive copy of myCookbooks
const myCookbooks = ref<ReadCookBook[]>([]);
watch(
allCookbooks,
(cookbooks) => {
myCookbooks.value
= cookbooks?.filter(
cookbook => cookbook.householdId === $auth.user.value?.householdId,
) ?? [];
},
{ immediate: true },
);
const { household } = useHouseholdSelf();
const cookbookPreferences = useCookbookPreferences();
// create
const createTargetKey = ref(0);
const createTarget = ref<ReadCookBook | null>(null);
async function createCookbook() {
const name = i18n.t("cookbook.household-cookbook-name", [
household.value?.name || "",
String((myCookbooks.value?.length ?? 0) + 1),
]) as string;
await actions.createOne(name).then((cookbook) => {
if (!cookbook) {
return;
}
myCookbooks.value.push(cookbook);
createTarget.value = cookbook as ReadCookBook;
createTargetKey.value++;
});
dialogStates.create = true;
}
// delete
const deleteTarget = ref<ReadCookBook | null>(null);
function deleteEventHandler(item: ReadCookBook) {
deleteTarget.value = item;
dialogStates.delete = true;
}
async function deleteCookbook() {
if (!deleteTarget.value) {
return;
}
await actions.deleteOne(deleteTarget.value.id);
myCookbooks.value = myCookbooks.value.filter(c => c.id !== deleteTarget.value?.id);
dialogStates.delete = false;
deleteTarget.value = null;
}
async function deleteCreateTarget() {
if (!createTarget.value?.id) {
return;
}
await actions.deleteOne(createTarget.value.id);
myCookbooks.value = myCookbooks.value.filter(c => c.id !== createTarget.value?.id);
dialogStates.create = false;
createTarget.value = null;
}
function handleUnmount() {
if (!createTarget.value?.id || createTarget.value.queryFilterString) {
return;
}
deleteCreateTarget();
}
onMounted(() => {
window.addEventListener("beforeunload", handleUnmount);
});
onBeforeUnmount(() => {
handleUnmount();
window.removeEventListener("beforeunload", handleUnmount);
});
return {
myCookbooks,
cookbookPreferences,
actions,
dialogStates,
// create
createTargetKey,
createTarget,
createCookbook,
// delete
deleteTarget,
deleteEventHandler,
deleteCookbook,
deleteCreateTarget,
};
},
});
</script>

View file

@ -5,10 +5,9 @@
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import RecipeExplorerPage from "~/components/Domain/Recipe/RecipeExplorerPage.vue";
export default defineComponent({
export default defineNuxtComponent({
components: { RecipeExplorerPage },
});
</script>

View file

@ -0,0 +1,58 @@
<template>
<div>
<RecipePage
v-if="recipe"
v-model="recipe"
/>
</div>
</template>
<script setup lang="ts">
import { whenever } from "@vueuse/core";
import { useLoggedInState } from "~/composables/use-logged-in-state";
import { useAsyncKey } from "~/composables/use-utils";
import RecipePage from "~/components/Domain/Recipe/RecipePage/RecipePage.vue";
import { usePublicExploreApi } from "~/composables/api/api-client";
import { useRecipe } from "~/composables/recipes";
import type { Recipe } from "~/lib/api/types/recipe";
const $auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState();
const route = useRoute();
const title = ref(route.meta?.title ?? "");
useSeoMeta({ title });
const router = useRouter();
const slug = route.params.slug as string;
const recipe = ref<Recipe | null>(null);
if (isOwnGroup.value) {
const { recipe: data } = useRecipe(slug);
watch(data, (value) => {
recipe.value = value;
});
}
else {
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const api = usePublicExploreApi(groupSlug.value);
const { data } = await useAsyncData(useAsyncKey(), async () => {
const { data, error } = await api.explore.recipes.getOne(slug);
if (error) {
console.error("error loading recipe -> ", error);
router.push(`/g/${groupSlug.value}`);
}
return data;
});
recipe.value = data.value;
}
whenever(
() => recipe.value,
() => {
if (recipe.value && recipe.value.name) {
title.value = recipe.value.name;
}
},
);
</script>

View file

@ -1,14 +1,18 @@
<template>
<v-container v-if="recipe">
<v-container>
<BaseCardSectionTitle :title="$tc('recipe.parser.ingredient-parser')">
<div class="mt-4">{{ $tc("recipe.parser.explanation") }}</div>
<BaseCardSectionTitle :title="$t('recipe.parser.ingredient-parser')">
<div class="mt-4">
{{ $t("recipe.parser.explanation") }}
</div>
<div class="my-4">
{{ $tc("recipe.parser.alerts-explainer") }}
{{ $t("recipe.parser.alerts-explainer") }}
</div>
<div class="d-flex align-center mb-n4">
<div class="mb-4">{{ $tc("recipe.parser.select-parser") }}</div>
<div class="mb-4">
{{ $t("recipe.parser.select-parser") }}
</div>
<BaseOverflowButton
v-model="parser"
btn-class="mx-2 mb-4"
@ -17,13 +21,30 @@
</div>
</BaseCardSectionTitle>
<div class="d-flex mt-n3 mb-4 justify-end" style="gap: 5px">
<BaseButton cancel class="mr-auto" @click="$router.go(-1)"></BaseButton>
<BaseButton color="info" :disabled="parserLoading" @click="fetchParsed">
<template #icon> {{ $globals.icons.foods }}</template>
{{ $tc("recipe.parser.parse-all") }}
<div
class="d-flex mt-n3 mb-4 justify-end"
style="gap: 5px"
>
<BaseButton
cancel
class="mr-auto"
@click="$router.go(-1)"
/>
<BaseButton
color="info"
:disabled="parserLoading"
@click="fetchParsed"
>
<template #icon>
{{ $globals.icons.foods }}
</template>
{{ $t("recipe.parser.parse-all") }}
</BaseButton>
<BaseButton save :disabled="parserLoading" @click="saveAll" />
<BaseButton
save
:disabled="parserLoading"
@click="saveAll"
/>
</div>
<div v-if="parserLoading">
@ -34,57 +55,80 @@
/>
</div>
<div v-else>
<v-expansion-panels v-model="panels" multiple>
<draggable
<v-expansion-panels
v-model="panels"
multiple
>
<VueDraggable
v-if="parsedIng.length > 0"
v-model="parsedIng"
handle=".handle"
delay="250"
:delay="250"
:delay-on-touch-only="true"
:style="{ width: '100%' }"
ghost-class="ghost"
>
<v-expansion-panel v-for="(ing, index) in parsedIng" :key="index">
<v-expansion-panel-header class="my-0 py-0" disable-icon-rotate>
<template #default="{ open }">
<v-expansion-panel
v-for="(ing, index) in parsedIng"
:key="index"
>
<v-expansion-panel-title
class="my-0 py-0"
disable-icon-rotate
>
<template #default="{ expanded }">
<v-fade-transition>
<span v-if="!open" key="0"> {{ ing.input }} </span>
<span
v-if="!expanded"
key="0"
> {{ ing.input }} </span>
</v-fade-transition>
</template>
<template #actions>
<v-icon left :color="isError(ing) ? 'error' : 'success'">
<v-icon
start
:color="isError(ing) ? 'error' : 'success'"
>
{{ isError(ing) ? $globals.icons.alert : $globals.icons.check }}
</v-icon>
<div class="my-auto" :color="isError(ing) ? 'error-text' : 'success-text'">
{{ ing.confidence ? asPercentage(ing.confidence.average) : "" }}
<div
class="my-auto"
:color="isError(ing) ? 'error-text' : 'success-text'"
>
{{ ing.confidence ? asPercentage(ing.confidence.average!) : "" }}
</div>
</template>
</v-expansion-panel-header>
<v-expansion-panel-content class="pb-0 mb-0">
<RecipeIngredientEditor v-model="parsedIng[index].ingredient" allow-insert-ingredient @insert-ingredient="insertIngredient(index)" @delete="deleteIngredient(index)" />
</v-expansion-panel-title>
<v-expansion-panel-text class="pb-0 mb-0">
<RecipeIngredientEditor
v-model="parsedIng[index].ingredient"
allow-insert-ingredient
@insert-ingredient="insertIngredient(index)"
@delete="deleteIngredient(index)"
/>
{{ ing.input }}
<v-card-actions>
<v-spacer />
<BaseButton
v-if="errors[index].unitError && errors[index].unitErrorMessage !== ''"
color="warning"
small
@click="createUnit(ing.ingredient.unit, index)"
size="small"
@click="createUnit(ing.ingredient.unit!, index)"
>
{{ errors[index].unitErrorMessage }}
</BaseButton>
<BaseButton
v-if="errors[index].foodError && errors[index].foodErrorMessage !== ''"
color="warning"
small
@click="createFood(ing.ingredient.food, index)"
size="small"
@click="createFood(ing.ingredient.food!, index)"
>
{{ errors[index].foodErrorMessage }}
</BaseButton>
</v-card-actions>
</v-expansion-panel-content>
</v-expansion-panel-text>
</v-expansion-panel>
</draggable>
</VueDraggable>
</v-expansion-panels>
</div>
</v-container>
@ -92,9 +136,8 @@
</template>
<script lang="ts">
import { computed, defineComponent, ref, useContext, useRoute, useRouter, watch } from "@nuxtjs/composition-api";
import { invoke, until } from "@vueuse/core";
import draggable from "vuedraggable";
import { VueDraggable } from "vue-draggable-plus";
import RecipeIngredientEditor from "~/components/Domain/Recipe/RecipeIngredientEditor.vue";
import { alert } from "~/composables/use-toast";
import { useAppInfo, useUserApi } from "~/composables/api";
@ -102,7 +145,7 @@ import { useRecipe } from "~/composables/recipes";
import { useFoodData, useFoodStore, useUnitData, useUnitStore } from "~/composables/store";
import { useParsingPreferences } from "~/composables/use-users/preferences";
import { uuid4 } from "~/composables/use-utils";
import {
import type {
CreateIngredientFood,
CreateIngredientUnit,
IngredientFood,
@ -110,7 +153,7 @@ import {
ParsedIngredient,
RecipeIngredient,
} from "~/lib/api/types/recipe";
import { Parser } from "~/lib/api/user/recipes/recipe";
import type { Parser } from "~/lib/api/user/recipes/recipe";
interface Error {
ingredientIndex: number;
@ -120,21 +163,22 @@ interface Error {
foodErrorMessage: string;
}
export default defineComponent({
export default defineNuxtComponent({
components: {
RecipeIngredientEditor,
draggable
VueDraggable,
},
middleware: ["auth", "group-only"],
middleware: ["sidebase-auth", "group-only"],
setup() {
const { $auth, i18n } = useContext();
const i18n = useI18n();
const $auth = useMealieAuth();
const panels = ref<number[]>([]);
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const router = useRouter();
const slug = route.value.params.slug;
const slug = route.params.slug as string;
const api = useUserApi();
const appInfo = useAppInfo();
@ -152,19 +196,19 @@ export default defineComponent({
const availableParsers = computed(() => {
return [
{
"text": i18n.tc("recipe.parser.natural-language-processor"),
"value": "nlp",
text: i18n.t("recipe.parser.natural-language-processor"),
value: "nlp",
},
{
"text": i18n.tc("recipe.parser.brute-parser"),
"value": "brute",
text: i18n.t("recipe.parser.brute-parser"),
value: "brute",
},
{
"text": i18n.tc("recipe.parser.openai-parser"),
"value": "openai",
"hide": !appInfo.value?.enableOpenai,
text: i18n.t("recipe.parser.openai-parser"),
value: "openai",
hide: !appInfo.value?.enableOpenai,
},
]
];
});
// =========================================================
@ -177,8 +221,8 @@ export default defineComponent({
});
function processIngredientError(ing: ParsedIngredient, index: number): Error {
const unitError = !checkForUnit(ing.ingredient.unit);
const foodError = !checkForFood(ing.ingredient.food);
const unitError = !checkForUnit(ing.ingredient.unit!);
const foodError = !checkForFood(ing.ingredient.food!);
let unitErrorMessage = "";
let foodErrorMessage = "";
@ -186,14 +230,14 @@ export default defineComponent({
if (unitError || foodError) {
if (unitError) {
if (ing?.ingredient?.unit?.name) {
const unit = ing.ingredient.unit.name || i18n.tc("recipe.parser.no-unit");
const unit = ing.ingredient.unit.name || i18n.t("recipe.parser.no-unit");
unitErrorMessage = i18n.t("recipe.parser.missing-unit", { unit }).toString();
}
}
if (foodError) {
if (ing?.ingredient?.food?.name) {
const food = ing.ingredient.food.name || i18n.tc("recipe.parser.no-food");
const food = ing.ingredient.food.name || i18n.t("recipe.parser.no-food");
foodErrorMessage = i18n.t("recipe.parser.missing-food", { food }).toString();
}
}
@ -213,7 +257,7 @@ export default defineComponent({
if (!recipe.value || !recipe.value.recipeIngredient) {
return;
}
const raw = recipe.value.recipeIngredient.map((ing) => ing.note ?? "");
const raw = recipe.value.recipeIngredient.map(ing => ing.note ?? "");
parserLoading.value = true;
const { data } = await api.recipes.parseIngredients(parser.value, raw);
@ -226,7 +270,8 @@ export default defineComponent({
for (let i = 0; i < recipe.value.recipeIngredient.length; i++) {
data[i].ingredient.title = recipe.value.recipeIngredient[i].title;
}
} catch (TypeError) {
}
catch {
console.error("Index Mismatch Error during recipe ingredient parsing; did the number of ingredients change?");
}
@ -235,7 +280,8 @@ export default defineComponent({
errors.value = data.map((ing, index: number) => {
return processIngredientError(ing, index);
});
} else {
}
else {
alert.error(i18n.t("events.something-went-wrong") as string);
parsedIng.value = [];
}
@ -310,7 +356,7 @@ export default defineComponent({
quantity: 1.0,
disableAmount: false,
referenceId: uuid4(),
}
},
} as ParsedIngredient;
parsedIng.value.splice(index, 0, ing);
@ -334,11 +380,11 @@ export default defineComponent({
// Save All Logic
async function saveAll() {
const ingredients = parsedIng.value.map((ing) => {
if (!checkForFood(ing.ingredient.food)) {
if (!checkForFood(ing.ingredient.food!)) {
ing.ingredient.food = undefined;
}
if (!checkForUnit(ing.ingredient.unit)) {
if (!checkForUnit(ing.ingredient.unit!)) {
ing.ingredient.unit = undefined;
}
@ -364,6 +410,10 @@ export default defineComponent({
}
}
useSeoMeta({
title: i18n.t("recipe.parser.ingredient-parser"),
});
return {
parser,
availableParsers,
@ -386,10 +436,5 @@ export default defineComponent({
ingredients,
};
},
head() {
return {
title: this.$tc("recipe.parser.ingredient-parser"),
};
},
});
</script>

View file

@ -3,40 +3,61 @@
<v-container class="flex-column">
<BasePageTitle divider>
<template #header>
<v-img max-height="175" max-width="175" :src="require('~/static/svgs/recipes-create.svg')"></v-img>
<v-img
width="100%"
max-height="175"
max-width="175"
:src="require('~/static/svgs/recipes-create.svg')"
/>
</template>
<template #title>
{{ $t('recipe.recipe-creation') }}
</template>
<template #title> {{ $t('recipe.recipe-creation') }} </template>
{{ $t('recipe.select-one-of-the-various-ways-to-create-a-recipe') }}
<template #content>
<div class="ml-auto">
<BaseOverflowButton v-model="subpage" rounded :items="subpages"> </BaseOverflowButton>
<div class="flex-1-1 d-flex flex-column justify-center align-center ga-2">
<p>{{ $t('recipe.select-one-of-the-various-ways-to-create-a-recipe') }}</p>
<div class="ml-auto">
<BaseOverflowButton
v-model="subpage"
rounded
:items="subpages"
/>
</div>
</div>
</template>
</BasePageTitle>
<section>
<NuxtChild />
<NuxtPage />
</section>
</v-container>
<AdvancedOnly>
<v-container class="d-flex justify-center align-center my-4">
<router-link :to="`/group/migrations`"> {{ $t('recipe.looking-for-migrations') }}</router-link>
<router-link
:to="`/group/migrations`"
class="text-primary"
> {{ $t('recipe.looking-for-migrations') }}</router-link>
</v-container>
</AdvancedOnly>
</div>
</template>
<script lang="ts">
import { defineComponent, useRouter, useContext, computed, useRoute } from "@nuxtjs/composition-api";
import { useAppInfo } from "~/composables/api";
import { MenuItem } from "~/components/global/BaseOverflowButton.vue";
import type { MenuItem } from "~/components/global/BaseOverflowButton.vue";
import AdvancedOnly from "~/components/global/AdvancedOnly.vue";
export default defineComponent({
export default defineNuxtComponent({
components: { AdvancedOnly },
middleware: ["auth", "group-only"],
middleware: ["sidebase-auth", "group-only"],
setup() {
const { $auth, $globals, i18n } = useContext();
const i18n = useI18n();
const $auth = useMealieAuth();
const $globals = useNuxtApp().$globals;
useSeoMeta({
title: i18n.t("general.create"),
});
const appInfo = useAppInfo();
const enableOpenAIImages = computed(() => appInfo.value?.enableOpenaiImageServices);
@ -44,52 +65,52 @@ export default defineComponent({
const subpages = computed<MenuItem[]>(() => [
{
icon: $globals.icons.link,
text: i18n.tc("recipe.import-with-url"),
text: i18n.t("recipe.import-with-url"),
value: "url",
},
{
icon: $globals.icons.link,
text: i18n.tc("recipe.bulk-url-import"),
text: i18n.t("recipe.bulk-url-import"),
value: "bulk",
},
{
icon: $globals.icons.codeTags,
text: i18n.tc("recipe.import-from-html-or-json"),
text: i18n.t("recipe.import-from-html-or-json"),
value: "html",
},
{
icon: $globals.icons.fileImage,
text: i18n.tc("recipe.create-from-image"),
text: i18n.t("recipe.create-from-image"),
value: "image",
hide: !enableOpenAIImages.value,
},
{
icon: $globals.icons.edit,
text: i18n.tc("recipe.create-recipe"),
text: i18n.t("recipe.create-recipe"),
value: "new",
},
{
icon: $globals.icons.zip,
text: i18n.tc("recipe.import-with-zip"),
text: i18n.t("recipe.import-with-zip"),
value: "zip",
},
{
icon: $globals.icons.robot,
text: i18n.tc("recipe.debug-scraper"),
text: i18n.t("recipe.debug-scraper"),
value: "debug",
},
]);
const route = useRoute();
const router = useRouter();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || "");
const subpage = computed({
set(subpage: string) {
router.push({ path: `/g/${groupSlug.value}/r/create/${subpage}`, query: route.value.query });
router.push({ path: `/g/${groupSlug.value}/r/create/${subpage}`, query: route.query });
},
get() {
return route.value.path.split("/").pop() ?? "url";
return route.path.split("/").pop() ?? "url";
},
});
@ -99,10 +120,5 @@ export default defineComponent({
subpage,
};
},
head() {
return {
title: this.$t("general.create") as string,
};
},
});
</script>

View file

@ -1,22 +1,34 @@
<template>
<div>
<div>
<v-card-title class="headline"> {{ $t('recipe.recipe-bulk-importer') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.recipe-bulk-importer') }}
</v-card-title>
<v-card-text>
{{ $t('recipe.recipe-bulk-importer-description') }}
</v-card-text>
</div>
<section class="mt-2">
<v-row v-for="(_, idx) in bulkUrls" :key="'bulk-url' + idx" class="my-1" dense>
<v-col cols="12" xs="12" sm="12" md="12">
<v-row
v-for="(_, idx) in bulkUrls"
:key="'bulk-url' + idx"
class="my-1"
density="compact"
>
<v-col
cols="12"
xs="12"
sm="12"
md="12"
>
<v-text-field
v-model="bulkUrls[idx].url"
:label="$t('new-recipe.recipe-url')"
dense
density="compact"
single-line
validate-on-blur
validate-on="blur"
autofocus
filled
variant="solo-filled"
hide-details
clearable
:prepend-inner-icon="$globals.icons.link"
@ -24,7 +36,12 @@
class="rounded-lg"
>
<template #append>
<v-btn style="margin-top: -2px" icon small @click="bulkUrls.splice(idx, 1)">
<v-btn
style="margin-top: -2px"
icon
size="small"
@click="bulkUrls.splice(idx, 1)"
>
<v-icon>
{{ $globals.icons.delete }}
</v-icon>
@ -33,14 +50,18 @@
</v-text-field>
</v-col>
<template v-if="showCatTags">
<v-col cols="12" xs="12" sm="6">
<v-col
cols="12"
xs="12"
sm="6"
>
<RecipeOrganizerSelector
v-model="bulkUrls[idx].categories"
selector-type="categories"
:input-attrs="{
filled: true,
variant: 'filled',
singleLine: true,
dense: true,
density: 'compact',
rounded: true,
class: 'rounded-lg',
hideDetails: true,
@ -48,14 +69,18 @@
}"
/>
</v-col>
<v-col cols="12" xs="12" sm="6">
<v-col
cols="12"
xs="12"
sm="6"
>
<RecipeOrganizerSelector
v-model="bulkUrls[idx].tags"
selector-type="tags"
:input-attrs="{
filled: true,
variant: 'filled',
singleLine: true,
dense: true,
density: 'compact',
rounded: true,
class: 'rounded-lg',
hideDetails: true,
@ -75,40 +100,61 @@
>
{{ $t('general.clear') }}
</BaseButton>
<v-spacer></v-spacer>
<BaseButton class="mr-1 mb-1" color="info" @click="bulkUrls.push({ url: '', categories: [], tags: [] })">
<template #icon> {{ $globals.icons.createAlt }} </template>
<v-spacer />
<BaseButton
class="mr-1 mb-1"
color="info"
@click="bulkUrls.push({ url: '', categories: [], tags: [] })"
>
<template #icon>
{{ $globals.icons.createAlt }}
</template>
{{ $t('general.new') }}
</BaseButton>
<RecipeDialogBulkAdd v-model="bulkDialog" class="mr-1 mr-sm-0 mb-1" @bulk-data="assignUrls" />
<RecipeDialogBulkAdd
v-model="bulkDialog"
class="mr-1 mr-sm-0 mb-1"
@bulk-data="assignUrls"
/>
</v-card-actions>
<div class="px-1">
<v-checkbox v-model="showCatTags" hide-details :label="$t('recipe.set-categories-and-tags')" />
<v-checkbox
v-model="showCatTags"
hide-details
:label="$t('recipe.set-categories-and-tags')"
/>
</div>
<v-card-actions class="justify-end">
<BaseButton :disabled="bulkUrls.length === 0 || lockBulkImport" @click="bulkCreate">
<template #icon> {{ $globals.icons.check }} </template>
<BaseButton
:disabled="bulkUrls.length === 0 || lockBulkImport"
@click="bulkCreate"
>
<template #icon>
{{ $globals.icons.check }}
</template>
{{ $t('general.submit') }}
</BaseButton>
</v-card-actions>
</section>
<section class="mt-12">
<BaseCardSectionTitle :title="$tc('recipe.bulk-imports')"> </BaseCardSectionTitle>
<ReportTable :items="reports" @delete="deleteReport" />
<BaseCardSectionTitle :title="$t('recipe.bulk-imports')" />
<ReportTable
:items="reports"
@delete="deleteReport"
/>
</section>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs, ref, useContext } from "@nuxtjs/composition-api";
import { whenever } from "@vueuse/shared";
import { useUserApi } from "~/composables/api";
import { alert } from "~/composables/use-toast";
import RecipeOrganizerSelector from "~/components/Domain/Recipe/RecipeOrganizerSelector.vue";
import { ReportSummary } from "~/lib/api/types/reports";
import type { ReportSummary } from "~/lib/api/types/reports";
import RecipeDialogBulkAdd from "~/components/Domain/Recipe/RecipeDialogBulkAdd.vue";
export default defineComponent({
export default defineNuxtComponent({
components: { RecipeOrganizerSelector, RecipeDialogBulkAdd },
setup() {
const state = reactive({
@ -122,11 +168,11 @@ export default defineComponent({
() => !state.showCatTags,
() => {
console.log("showCatTags changed");
}
},
);
const api = useUserApi();
const { i18n } = useContext();
const i18n = useI18n();
const bulkUrls = ref([{ url: "", categories: [], tags: [] }]);
const lockBulkImport = ref(false);
@ -139,10 +185,11 @@ export default defineComponent({
const { response } = await api.recipes.createManyByUrl({ imports: bulkUrls.value });
if (response?.status === 202) {
alert.success(i18n.tc("recipe.bulk-import-process-has-started"));
alert.success(i18n.t("recipe.bulk-import-process-has-started"));
lockBulkImport.value = true;
} else {
alert.error(i18n.tc("recipe.bulk-import-process-has-failed"));
}
else {
alert.error(i18n.t("recipe.bulk-import-process-has-failed"));
}
fetchReports();
@ -164,15 +211,16 @@ export default defineComponent({
if (response?.status === 200) {
fetchReports();
} else {
alert.error(i18n.tc("recipe.report-deletion-failed"));
}
else {
alert.error(i18n.t("recipe.report-deletion-failed"));
}
}
fetchReports();
function assignUrls(urls: string[]) {
bulkUrls.value = urls.map((url) => ({ url, categories: [], tags: [] }));
bulkUrls.value = urls.map(url => ({ url, categories: [], tags: [] }));
}
return {

View file

@ -1,17 +1,22 @@
<template>
<div>
<v-form ref="domUrlForm" @submit.prevent="debugUrl(recipeUrl)">
<v-form
ref="domUrlForm"
@submit.prevent="debugUrl(recipeUrl)"
>
<div>
<v-card-title class="headline"> {{ $t('recipe.recipe-debugger') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.recipe-debugger') }}
</v-card-title>
<v-card-text>
{{ $t('recipe.recipe-debugger-description') }}
<v-text-field
v-model="recipeUrl"
:label="$t('new-recipe.recipe-url')"
validate-on-blur
validate-on="blur"
:prepend-inner-icon="$globals.icons.link"
autofocus
filled
variant="solo-filled"
clearable
rounded
class="rounded-lg mt-2"
@ -22,11 +27,21 @@
</v-card-text>
<v-card-text v-if="appInfo && appInfo.enableOpenai">
{{ $t('recipe.recipe-debugger-use-openai-description') }}
<v-checkbox v-model="useOpenAI" :label="$t('recipe.use-openai')"></v-checkbox>
<v-checkbox
v-model="useOpenAI"
:label="$t('recipe.use-openai')"
/>
</v-card-text>
<v-card-actions class="justify-center">
<div style="width: 250px">
<BaseButton :disabled="recipeUrl === null" rounded block type="submit" color="info" :loading="loading">
<BaseButton
:disabled="recipeUrl === null"
rounded
block
type="submit"
color="info"
:loading="loading"
>
<template #icon>
{{ $globals.icons.robot }}
</template>
@ -37,29 +52,27 @@
</div>
</v-form>
<section v-if="debugData">
<v-checkbox v-model="debugTreeView" :label="$t('recipe.tree-view')"></v-checkbox>
<LazyRecipeJsonEditor
<v-checkbox
v-model="debugTreeView"
:label="$t('recipe.tree-view')"
/>
<RecipeJsonEditor
v-model="debugData"
class="primary"
:options="{
mode: debugTreeView ? 'tree' : 'code',
search: false,
indentation: 4,
mainMenuBar: false,
}"
height="700px"
:mode="debugTreeView ? 'tree' : 'text'"
:main-menu-bar="false"
:read-only="true"
/>
</section>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs, ref, useRouter, computed, useRoute } from "@nuxtjs/composition-api";
import { useAppInfo, useUserApi } from "~/composables/api";
import { validators } from "~/composables/use-validators";
import { Recipe } from "~/lib/api/types/recipe";
import type { Recipe } from "~/lib/api/types/recipe";
export default defineComponent({
export default defineNuxtComponent({
setup() {
const state = reactive({
error: false,
@ -76,11 +89,11 @@ export default defineComponent({
set(recipe_import_url: string | null) {
if (recipe_import_url !== null) {
recipe_import_url = recipe_import_url.trim();
router.replace({ query: { ...route.value.query, recipe_import_url } });
router.replace({ query: { ...route.query, recipe_import_url } });
}
},
get() {
return route.value.query.recipe_import_url as string | null;
return route.query.recipe_import_url as string | null;
},
});

View file

@ -1,44 +1,61 @@
<template>
<v-form ref="domUrlForm" @submit.prevent="createFromHtmlOrJson(newRecipeData, importKeywordsAsTags, stayInEditMode)">
<v-form
ref="domUrlForm"
@submit.prevent="createFromHtmlOrJson(newRecipeData, importKeywordsAsTags, stayInEditMode)"
>
<div>
<v-card-title class="headline"> {{ $tc('recipe.import-from-html-or-json') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.import-from-html-or-json') }}
</v-card-title>
<v-card-text>
<p>
{{ $tc("recipe.import-from-html-or-json-description") }}
{{ $t("recipe.import-from-html-or-json-description") }}
</p>
<p>
{{ $tc("recipe.json-import-format-description-colon") }}
<a href="https://schema.org/Recipe" target="_blank">https://schema.org/Recipe</a>
{{ $t("recipe.json-import-format-description-colon") }}
<a
href="https://schema.org/Recipe"
target="_blank"
>https://schema.org/Recipe</a>
</p>
<v-switch
v-model="isEditJSON"
:label="$tc('recipe.json-editor')"
:label="$t('recipe.json-editor')"
class="mt-2"
@change="handleIsEditJson"
/>
<LazyRecipeJsonEditor
<RecipeJsonEditor
v-if="isEditJSON"
v-model="newRecipeData"
height="250px"
class="mt-10"
:options="EDITOR_OPTIONS"
mode="code"
:main-menu-bar="false"
/>
<v-textarea
v-else
v-model="newRecipeData"
:label="$tc('new-recipe.recipe-html-or-json')"
:label="$t('new-recipe.recipe-html-or-json')"
:prepend-inner-icon="$globals.icons.codeTags"
validate-on-blur
validate-on="blur"
autofocus
filled
variant="solo-filled"
clearable
class="rounded-lg mt-2"
rounded
:hint="$tc('new-recipe.url-form-hint')"
:hint="$t('new-recipe.url-form-hint')"
persistent-hint
/>
<v-checkbox v-model="importKeywordsAsTags" hide-details :label="$tc('recipe.import-original-keywords-as-tags')" />
<v-checkbox v-model="stayInEditMode" hide-details :label="$tc('recipe.stay-in-edit-mode')" />
<v-checkbox
v-model="importKeywordsAsTags"
hide-details
:label="$t('recipe.import-original-keywords-as-tags')"
/>
<v-checkbox
v-model="stayInEditMode"
hide-details
:label="$t('recipe.stay-in-edit-mode')"
/>
</v-card-text>
<v-card-actions class="justify-center">
<div style="width: 250px">
@ -57,29 +74,22 @@
</template>
<script lang="ts">
import { computed, defineComponent, reactive, toRefs, ref, useContext, useRoute, useRouter } from "@nuxtjs/composition-api";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useTagStore } from "~/composables/store/use-tag-store";
import { useUserApi } from "~/composables/api";
import { validators } from "~/composables/use-validators";
import { VForm } from "~/types/vuetify";
import type { VForm } from "~/types/auto-forms";
const EDITOR_OPTIONS = {
mode: "code",
search: false,
mainMenuBar: false,
};
export default defineComponent({
export default defineNuxtComponent({
setup() {
const state = reactive({
error: false,
loading: false,
isEditJSON: false,
});
const { $auth } = useContext();
const $auth = useMealieAuth();
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const domUrlForm = ref<VForm | null>(null);
const api = useUserApi();
@ -88,19 +98,19 @@ export default defineComponent({
const importKeywordsAsTags = computed({
get() {
return route.value.query.use_keywords === "1";
return route.query.use_keywords === "1";
},
set(v: boolean) {
router.replace({ query: { ...route.value.query, use_keywords: v ? "1" : "0" } });
router.replace({ query: { ...route.query, use_keywords: v ? "1" : "0" } });
},
});
const stayInEditMode = computed({
get() {
return route.value.query.edit === "1";
return route.query.edit === "1";
},
set(v: boolean) {
router.replace({ query: { ...route.value.query, edit: v ? "1" : "0" } });
router.replace({ query: { ...route.query, edit: v ? "1" : "0" } });
},
});
@ -124,15 +134,19 @@ export default defineComponent({
if (newRecipeData.value) {
try {
newRecipeData.value = JSON.parse(newRecipeData.value as string);
} catch {
newRecipeData.value = { "data": newRecipeData.value };
}
} else {
catch {
newRecipeData.value = { data: newRecipeData.value };
}
}
else {
newRecipeData.value = {};
}
} else if (newRecipeData.value && Object.keys(newRecipeData.value).length > 0) {
}
else if (newRecipeData.value && Object.keys(newRecipeData.value).length > 0) {
newRecipeData.value = JSON.stringify(newRecipeData.value);
} else {
}
else {
newRecipeData.value = null;
}
}
@ -146,7 +160,8 @@ export default defineComponent({
let dataString;
if (typeof htmlOrJsonData === "string") {
dataString = htmlOrJsonData;
} else {
}
else {
dataString = JSON.stringify(htmlOrJsonData);
}
@ -156,7 +171,6 @@ export default defineComponent({
}
return {
EDITOR_OPTIONS,
domUrlForm,
importKeywordsAsTags,
stayInEditMode,

View file

@ -1,20 +1,28 @@
<template>
<div>
<v-form ref="domUrlForm" @submit.prevent="createRecipe">
<v-form
ref="domUrlForm"
@submit.prevent="createRecipe"
>
<div>
<v-card-title class="headline"> {{ $t('recipe.create-recipe-from-an-image') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.create-recipe-from-an-image') }}
</v-card-title>
<v-card-text>
<p>{{ $t('recipe.create-recipe-from-an-image-description') }}</p>
<v-container class="pa-0">
<v-row>
<v-col cols="auto" align-self="center">
<v-col
cols="auto"
align-self="center"
>
<AppButtonUpload
v-if="!uploadedImage"
class="ml-auto"
url="none"
file-name="image"
accept="image/*"
:text="$i18n.tc('recipe.upload-image')"
:text="$t('recipe.upload-image')"
:text-btn="false"
:post="false"
@uploaded="uploadImage"
@ -24,16 +32,24 @@
color="error"
@click="clearImage"
>
<v-icon left>{{ $globals.icons.close }}</v-icon>
{{ $i18n.tc('recipe.remove-image') }}
<v-icon start>
{{ $globals.icons.close }}
</v-icon>
{{ $t('recipe.remove-image') }}
</v-btn>
</v-col>
<v-spacer />
</v-row>
<div v-if="uploadedImage && uploadedImagePreviewUrl" class="mt-3">
<div
v-if="uploadedImage && uploadedImagePreviewUrl"
class="mt-3"
>
<v-row>
<v-col cols="12" class="pb-0">
<v-col
cols="12"
class="pb-0"
>
<v-card-text class="pa-0">
<p class="mb-0">
{{ $t('recipe.crop-and-rotate-the-image') }}
@ -59,7 +75,12 @@
<v-card-actions v-if="uploadedImage">
<div>
<p style="width: 250px">
<BaseButton rounded block type="submit" :loading="loading" />
<BaseButton
rounded
block
type="submit"
:loading="loading"
/>
</p>
<p>
<v-checkbox
@ -69,7 +90,10 @@
:disabled="loading"
/>
</p>
<p v-if="loading" class="mb-0">
<p
v-if="loading"
class="mb-0"
>
{{ $t('recipe.please-wait-image-procesing') }}
</p>
</div>
@ -80,31 +104,21 @@
</template>
<script lang="ts">
import {
computed,
defineComponent,
reactive,
ref,
toRefs,
useContext,
useRoute,
useRouter,
} from "@nuxtjs/composition-api";
import { useUserApi } from "~/composables/api";
import { alert } from "~/composables/use-toast";
import { VForm } from "~/types/vuetify";
import type { VForm } from "~/types/auto-forms";
export default defineComponent({
export default defineNuxtComponent({
setup() {
const state = reactive({
loading: false,
});
const { i18n } = useContext();
const i18n = useI18n();
const api = useUserApi();
const route = useRoute();
const router = useRouter();
const groupSlug = computed(() => route.value.params.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug || "");
const domUrlForm = ref<VForm | null>(null);
const uploadedImage = ref<Blob | File>();
@ -138,9 +152,10 @@ export default defineComponent({
const translateLanguage = shouldTranslate.value ? i18n.locale : undefined;
const { data, error } = await api.recipes.createOneFromImage(uploadedImage.value, uploadedImageName.value, translateLanguage);
if (error || !data) {
alert.error(i18n.tc("events.something-went-wrong"));
alert.error(i18n.t("events.something-went-wrong"));
state.loading = false;
} else {
}
else {
router.push(`/g/${groupSlug.value}/r/${data}`);
};
}

View file

@ -1,11 +1,9 @@
<template>
<div></div>
<div />
</template>
<script lang="ts">
import { defineComponent, onMounted, useRouter } from "@nuxtjs/composition-api";
export default defineComponent({
export default defineNuxtComponent({
setup() {
const router = useRouter();
onMounted(() => {

View file

@ -1,24 +1,30 @@
<template>
<div>
<v-card-title class="headline"> {{ $t('recipe.create-recipe') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.create-recipe') }}
</v-card-title>
<v-card-text>
{{ $t('recipe.create-a-recipe-by-providing-the-name-all-recipes-must-have-unique-names') }}
<v-form ref="domCreateByName" @submit.prevent>
<v-form
ref="domCreateByName"
@submit.prevent
>
<v-text-field
v-model="newRecipeName"
:label="$t('recipe.recipe-name')"
:prepend-inner-icon="$globals.icons.primary"
validate-on-blur
validate-on="blur"
autofocus
filled
variant="solo-filled"
clearable
class="rounded-lg mt-2"
color="primary"
rounded
:rules="[validators.required]"
:hint="$t('recipe.new-recipe-names-must-be-unique')"
persistent-hint
@keyup.enter="createByName(newRecipeName)"
></v-text-field>
/>
</v-form>
</v-card-text>
<v-card-actions class="justify-center">
@ -34,22 +40,22 @@
</v-card-actions>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs, ref, useContext, useRouter, computed, useRoute } from "@nuxtjs/composition-api";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useUserApi } from "~/composables/api";
import { validators } from "~/composables/use-validators";
import { VForm } from "~/types/vuetify";
import type { VForm } from "~/types/auto-forms";
export default defineComponent({
export default defineNuxtComponent({
setup() {
const state = reactive({
error: false,
loading: false,
});
const { $auth } = useContext();
const $auth = useMealieAuth();
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const api = useUserApi();
const router = useRouter();
@ -71,9 +77,7 @@ export default defineComponent({
return;
}
const { response } = await api.recipes.createOne({ name });
// TODO createOne claims to return a Recipe, but actually the API only returns a string
// @ts-ignore See above
handleResponse(response, true);
handleResponse(response as any, true);
}
return {
domCreateByName,

View file

@ -1,14 +1,19 @@
<template>
<div>
<v-form ref="domUrlForm" @submit.prevent="createByUrl(recipeUrl, importKeywordsAsTags, stayInEditMode)">
<v-form
ref="domUrlForm"
@submit.prevent="createByUrl(recipeUrl, importKeywordsAsTags, stayInEditMode)"
>
<div>
<v-card-title class="headline"> {{ $t('recipe.scrape-recipe') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.scrape-recipe') }}
</v-card-title>
<v-card-text>
<p>{{ $t('recipe.scrape-recipe-description') }}</p>
<p>
{{ $t('recipe.scrape-recipe-have-a-lot-of-recipes') }}
<a :href="bulkImporterTarget">{{ $t('recipe.scrape-recipe-suggest-bulk-importer') }}</a>.
<br />
<br>
{{ $t('recipe.scrape-recipe-have-raw-html-or-json-data') }}
<a :href="htmlOrJsonImporterTarget">{{ $t('recipe.scrape-recipe-you-can-import-from-raw-data-directly') }}</a>.
</p>
@ -16,33 +21,59 @@
v-model="recipeUrl"
:label="$t('new-recipe.recipe-url')"
:prepend-inner-icon="$globals.icons.link"
validate-on-blur
validate-on="blur"
autofocus
filled
variant="solo-filled"
clearable
class="rounded-lg mt-2"
rounded
:rules="[validators.url]"
:hint="$t('new-recipe.url-form-hint')"
persistent-hint
></v-text-field>
<v-checkbox v-model="importKeywordsAsTags" hide-details :label="$t('recipe.import-original-keywords-as-tags')" />
<v-checkbox v-model="stayInEditMode" hide-details :label="$t('recipe.stay-in-edit-mode')" />
/>
</v-card-text>
<v-checkbox
v-model="importKeywordsAsTags"
color="primary"
hide-details
:label="$t('recipe.import-original-keywords-as-tags')"
/>
<v-checkbox
v-model="stayInEditMode"
color="primary"
hide-details
:label="$t('recipe.stay-in-edit-mode')"
/>
<v-card-actions class="justify-center">
<div style="width: 250px">
<BaseButton :disabled="recipeUrl === null" rounded block type="submit" :loading="loading" />
<BaseButton
:disabled="recipeUrl === null"
rounded
block
type="submit"
:loading="loading"
/>
</div>
</v-card-actions>
</div>
</v-form>
<v-expand-transition>
<v-alert v-show="error" color="error" class="mt-6 white--text">
<v-alert
v-if="error"
color="error"
class="mt-6 white--text"
>
<v-card-title class="ma-0 pa-0">
<v-icon left color="white" x-large> {{ $globals.icons.robot }} </v-icon>
<v-icon
start
color="white"
size="x-large"
>
{{ $globals.icons.robot }}
</v-icon>
{{ $t("new-recipe.error-title") }}
</v-card-title>
<v-divider class="my-3 mx-2"></v-divider>
<v-divider class="my-3 mx-2" />
<p>
{{ $t("new-recipe.error-details") }}
@ -56,10 +87,18 @@
>
{{ $t("new-recipe.google-ld-json-info") }}
</a>
<a href="https://github.com/hay-kot/mealie/issues" target="_blank" rel="noreferrer nofollow">
<a
href="https://github.com/hay-kot/mealie/issues"
target="_blank"
rel="noreferrer nofollow"
>
{{ $t("new-recipe.github-issues") }}
</a>
<a href="https://schema.org/Recipe" target="_blank" rel="noreferrer nofollow">
<a
href="https://schema.org/Recipe"
target="_blank"
rel="noreferrer nofollow"
>
{{ $t("new-recipe.recipe-markup-specification") }}
</a>
</div>
@ -69,34 +108,26 @@
</template>
<script lang="ts">
import {
defineComponent,
reactive,
toRefs,
ref,
useRouter,
computed,
useContext,
useRoute,
onMounted,
} from "@nuxtjs/composition-api";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useUserApi } from "~/composables/api";
import { useTagStore } from "~/composables/store/use-tag-store";
import { validators } from "~/composables/use-validators";
import { VForm } from "~/types/vuetify";
import type { VForm } from "~/types/auto-forms";
export default defineComponent({
export default defineNuxtComponent({
setup() {
definePageMeta({
key: route => route.path,
});
const state = reactive({
error: false,
loading: false,
});
const { $auth } = useContext();
const $auth = useMealieAuth();
const api = useUserApi();
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const router = useRouter();
const tags = useTagStore();
@ -116,7 +147,7 @@ export default defineComponent({
// we clear the query params first so if the user hits back, they don't re-import the recipe
router.replace({ query: {} }).then(
() => router.push(`/g/${groupSlug.value}/r/${response.data}?edit=${edit.toString()}`)
() => router.push(`/g/${groupSlug.value}/r/${response.data}?edit=${edit.toString()}`),
);
}
@ -124,29 +155,29 @@ export default defineComponent({
set(recipe_import_url: string | null) {
if (recipe_import_url !== null) {
recipe_import_url = recipe_import_url.trim();
router.replace({ query: { ...route.value.query, recipe_import_url } });
router.replace({ query: { ...route.query, recipe_import_url } });
}
},
get() {
return route.value.query.recipe_import_url as string | null;
return route.query.recipe_import_url as string | null;
},
});
const importKeywordsAsTags = computed({
get() {
return route.value.query.use_keywords === "1";
return route.query.use_keywords === "1";
},
set(v: boolean) {
router.replace({ query: { ...route.value.query, use_keywords: v ? "1" : "0" } });
router.replace({ query: { ...route.query, use_keywords: v ? "1" : "0" } });
},
});
const stayInEditMode = computed({
get() {
return route.value.query.edit === "1";
return route.query.edit === "1";
},
set(v: boolean) {
router.replace({ query: { ...route.value.query, edit: v ? "1" : "0" } });
router.replace({ query: { ...route.query, edit: v ? "1" : "0" } });
},
});

View file

@ -1,14 +1,16 @@
<template>
<v-form>
<div>
<v-card-title class="headline"> {{ $t('recipe.import-from-zip') }} </v-card-title>
<v-card-title class="headline">
{{ $t('recipe.import-from-zip') }}
</v-card-title>
<v-card-text>
{{ $t('recipe.import-from-zip-description') }}
<v-file-input
v-model="newRecipeZip"
accept=".zip"
label=".zip"
filled
variant="solo-filled"
clearable
class="rounded-lg mt-2"
rounded
@ -17,12 +19,18 @@
persistent-hint
prepend-icon=""
:prepend-inner-icon="$globals.icons.zip"
>
</v-file-input>
/>
</v-card-text>
<v-card-actions class="justify-center">
<div style="width: 250px">
<BaseButton :disabled="newRecipeZip === null" large rounded block :loading="loading" @click="createByZip" />
<BaseButton
:disabled="newRecipeZip === null"
large
rounded
block
:loading="loading"
@click="createByZip"
/>
</div>
</v-card-actions>
</div>
@ -30,20 +38,19 @@
</template>
<script lang="ts">
import { computed, defineComponent, reactive, toRefs, ref, useContext, useRoute, useRouter } from "@nuxtjs/composition-api";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useUserApi } from "~/composables/api";
import { validators } from "~/composables/use-validators";
export default defineComponent({
export default defineNuxtComponent({
setup() {
const state = reactive({
error: false,
loading: false,
});
const { $auth } = useContext();
const $auth = useMealieAuth();
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const api = useUserApi();
const router = useRouter();

View file

@ -8,33 +8,34 @@
@delete="actions.deleteOne"
@update="actions.updateOne"
>
<template #title> {{ $tc("category.categories") }} </template>
<template #title>
{{ $t("category.categories") }}
</template>
</RecipeOrganizerPage>
</v-container>
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import RecipeOrganizerPage from "~/components/Domain/Recipe/RecipeOrganizerPage.vue";
import { useCategoryStore } from "~/composables/store";
export default defineComponent({
export default defineNuxtComponent({
components: {
RecipeOrganizerPage,
},
middleware: ["auth", "group-only"],
middleware: ["sidebase-auth", "group-only"],
setup() {
const { store, actions } = useCategoryStore();
const i18n = useI18n();
useSeoMeta({
title: i18n.t("category.categories"),
});
return {
store,
actions,
};
},
head() {
return {
title: this.$tc("category.categories"),
};
},
});
</script>

View file

@ -2,54 +2,78 @@
<v-container>
<BasePageTitle divider>
<template #header>
<v-img max-height="100" max-width="100" :src="require('~/static/svgs/manage-cookbooks.svg')"></v-img>
<v-img
width="100"
max-height="100"
max-width="100"
:src="require('~/static/svgs/manage-cookbooks.svg')"
/>
</template>
<template #title>
{{ $t('recipe-finder.recipe-finder') }}
</template>
<template #content>
{{ $t('recipe-finder.recipe-finder-description') }}
</template>
<template #title> {{ $tc('recipe-finder.recipe-finder') }} </template>
{{ $t('recipe-finder.recipe-finder-description') }}
</BasePageTitle>
<v-container v-if="ready">
<v-row>
<v-col :cols="useMobile ? 12 : 3">
<v-container class="ma-0 pa-0">
<v-row no-gutters>
<v-col cols="12" no-gutters :class="attrs.searchFilter.colClass">
<SearchFilter v-if="foods" v-model="selectedFoods" :items="foods" :class="attrs.searchFilter.filterClass">
<v-icon left>
<v-col
cols="12"
no-gutters
:class="attrs.searchFilter.colClass"
>
<SearchFilter
v-if="foods"
v-model="selectedFoods"
:items="foods"
:class="attrs.searchFilter.filterClass"
>
<v-icon start>
{{ $globals.icons.foods }}
</v-icon>
{{ $t("general.foods") }}
</SearchFilter>
<SearchFilter v-if="tools" v-model="selectedTools" :items="tools" :class="attrs.searchFilter.filterClass">
<v-icon left>
<SearchFilter
v-if="tools"
v-model="selectedTools"
:items="tools"
:class="attrs.searchFilter.filterClass"
>
<v-icon start>
{{ $globals.icons.potSteam }}
</v-icon>
{{ $t("tool.tools") }}
</SearchFilter>
<div :class="attrs.searchFilter.filterClass">
<v-badge
:value="queryFilterJSON.parts && queryFilterJSON.parts.length"
small
overlap
:model-value="!!queryFilterJSON.parts && queryFilterJSON.parts.length > 0"
size="small"
color="primary"
:content="(queryFilterJSON.parts || []).length"
>
<v-btn
small
size="small"
color="accent"
dark
@click="queryFilterMenu = !queryFilterMenu"
>
<v-icon left>
<v-icon start>
{{ $globals.icons.filter }}
</v-icon>
{{ $tc("recipe-finder.other-filters") }}
{{ $t("recipe-finder.other-filters") }}
<BaseDialog
v-model="queryFilterMenu"
:title="$tc('recipe-finder.other-filters')"
:title="$t('recipe-finder.other-filters')"
:icon="$globals.icons.filter"
width="100%"
max-width="1100px"
:submit-disabled="!queryFilterEditorValue"
can-confirm
@confirm="saveQueryFilter"
>
<QueryFilterBuilder
@ -57,10 +81,14 @@
:initial-query-filter="queryFilterJSON"
:field-defs="queryFilterBuilderFields"
@input="(value) => queryFilterEditorValue = value"
@inputJSON="(value) => queryFilterEditorValueJSON = value"
@input-j-s-o-n="(value) => queryFilterEditorValueJSON = value"
/>
<template #custom-card-action>
<BaseButton color="error" type="submit" @click="clearQueryFilter">
<BaseButton
color="error"
type="submit"
@click="clearQueryFilter"
>
<template #icon>
{{ $globals.icons.close }}
</template>
@ -74,17 +102,28 @@
</v-col>
</v-row>
<!-- Settings Menu -->
<v-row no-gutters class="mb-2">
<v-col cols="12" :class="attrs.settings.colClass">
<v-row
no-gutters
class="mb-2"
>
<v-col
cols="12"
:class="attrs.settings.colClass"
>
<v-menu
v-model="settingsMenu"
offset-y
nudge-bottom="3"
:close-on-content-click="false"
>
<template #activator="{ on, attrs: activatorAttrs}">
<v-btn small color="primary" dark v-bind="activatorAttrs" v-on="on">
<v-icon left>
<template #activator="{ props }">
<v-btn
size="small"
color="primary"
dark
v-bind="props"
>
<v-icon start>
{{ $globals.icons.cog }}
</v-icon>
{{ $t("general.settings") }}
@ -98,14 +137,14 @@
type="number"
hide-details
hide-spin-buttons
:label="$tc('recipe-finder.max-missing-ingredients')"
:label="$t('recipe-finder.max-missing-ingredients')"
/>
<v-text-field
v-model="settings.maxMissingTools"
type="number"
hide-details
hide-spin-buttons
:label="$tc('recipe-finder.max-missing-tools')"
:label="$t('recipe-finder.max-missing-tools')"
class="mt-4"
/>
</div>
@ -113,20 +152,20 @@
<v-checkbox
v-if="isOwnGroup"
v-model="settings.includeFoodsOnHand"
dense
small
density="compact"
size="small"
hide-details
class="my-auto"
:label="$tc('recipe-finder.include-ingredients-on-hand')"
:label="$t('recipe-finder.include-ingredients-on-hand')"
/>
<v-checkbox
v-if="isOwnGroup"
v-model="settings.includeToolsOnHand"
dense
small
density="compact"
size="small"
hide-details
class="my-auto"
:label="$tc('recipe-finder.include-tools-on-hand')"
:label="$t('recipe-finder.include-tools-on-hand')"
/>
</div>
</v-card-text>
@ -134,29 +173,45 @@
</v-menu>
</v-col>
</v-row>
<v-row no-gutters class="my-2">
<v-row
no-gutters
class="my-2"
>
<v-col cols="12">
<v-divider />
</v-col>
</v-row>
<v-row no-gutters class="mt-5">
<v-row
no-gutters
class="mt-5"
>
<v-card-title class="ma-0 pa-0">
{{ $tc("recipe-finder.selected-ingredients") }}
{{ $t("recipe-finder.selected-ingredients") }}
</v-card-title>
<v-container class="ma-0 pa-0" style="max-height: 60vh; overflow-y: auto;">
<v-card-text v-if="!selectedFoods.length" class="ma-0 pa-0">
{{ $tc("recipe-finder.no-ingredients-selected") }}
<v-container
class="ma-0 pa-0"
style="max-height: 60vh; overflow-y: auto;"
>
<v-card-text
v-if="!selectedFoods.length"
class="ma-0 pa-0"
>
{{ $t("recipe-finder.no-ingredients-selected") }}
</v-card-text>
<div v-if="useMobile">
<v-row no-gutters>
<v-col cols="12" class="d-flex flex-wrap justify-end">
<v-col
cols="12"
class="d-flex flex-wrap justify-end"
>
<v-chip
v-for="food in selectedFoods"
:key="food.id"
label
class="ma-1"
color="accent custom-transparent"
close
closable
variant="flat"
@click:close="removeFood(food)"
>
<span class="text-hide-overflow">{{ food.pluralName || food.name }}</span>
@ -165,12 +220,18 @@
</v-row>
</div>
<div v-else>
<v-row v-for="food in selectedFoods" :key="food.id" no-gutters class="mb-1">
<v-row
v-for="food in selectedFoods"
:key="food.id"
no-gutters
class="mb-1"
>
<v-col cols="12">
<v-chip
label
color="accent custom-transparent"
close
variant="flat"
closable
@click:close="removeFood(food)"
>
<span class="text-hide-overflow">{{ food.pluralName || food.name }}</span>
@ -180,21 +241,29 @@
</div>
</v-container>
</v-row>
<v-row v-if="selectedTools.length" no-gutters class="mt-5">
<v-row
v-if="selectedTools.length"
no-gutters
class="mt-5"
>
<v-card-title class="ma-0 pa-0">
{{ $tc("recipe-finder.selected-tools") }}
{{ $t("recipe-finder.selected-tools") }}
</v-card-title>
<v-container class="ma-0 pa-0">
<div v-if="useMobile">
<v-row no-gutters>
<v-col cols="12" class="d-flex flex-wrap justify-end">
<v-col
cols="12"
class="d-flex flex-wrap justify-end"
>
<v-chip
v-for="tool in selectedTools"
:key="tool.id"
label
class="ma-1"
color="accent custom-transparent"
close
closeable
variant="flat"
@click:close="removeTool(tool)"
>
<span class="text-hide-overflow">{{ tool.name }}</span>
@ -203,12 +272,18 @@
</v-row>
</div>
<div v-else>
<v-row v-for="tool in selectedTools" :key="tool.id" no-gutters class="mb-1">
<v-row
v-for="tool in selectedTools"
:key="tool.id"
no-gutters
class="mb-1"
>
<v-col cols="12">
<v-chip
label
color="accent custom-transparent"
close
closable
variant="flat"
@click:close="removeTool(tool)"
>
<span class="text-hide-overflow">{{ tool.name }}</span>
@ -220,15 +295,21 @@
</v-row>
</v-container>
</v-col>
<v-col :cols="useMobile ? 12 : 9" :style="useMobile ? '' : 'max-height: 70vh; overflow-y: auto'">
<v-col
:cols="useMobile ? 12 : 9"
:style="useMobile ? '' : 'max-height: 70vh; overflow-y: auto'"
>
<v-container
v-if="recipeSuggestions.readyToMake.length || recipeSuggestions.missingItems.length"
class="ma-0 pa-0"
>
<v-row v-if="recipeSuggestions.readyToMake.length" dense>
<v-row
v-if="recipeSuggestions.readyToMake.length"
density="compact"
>
<v-col cols="12">
<v-card-title :class="attrs.title.class.readyToMake">
{{ $tc("recipe-finder.ready-to-make") }}
{{ $t("recipe-finder.ready-to-make") }}
</v-card-title>
</v-col>
<v-col
@ -250,10 +331,13 @@
</v-lazy>
</v-col>
</v-row>
<v-row v-if="recipeSuggestions.missingItems.length" dense>
<v-row
v-if="recipeSuggestions.missingItems.length"
density="compact"
>
<v-col cols="12">
<v-card-title :class="attrs.title.class.missingItems">
{{ $tc("recipe-finder.almost-ready-to-make") }}
{{ $t("recipe-finder.almost-ready-to-make") }}
</v-card-title>
</v-col>
<v-col
@ -261,24 +345,27 @@
:key="`${idx}-missing`"
cols="12"
>
<v-lazy>
<RecipeSuggestion
:recipe="item.recipe"
:missing-foods="item.missingFoods"
:missing-tools="item.missingTools"
:disable-checkbox="loading"
@add-food="addFood"
@remove-food="removeFood"
@add-tool="addTool"
@remove-tool="removeTool"
/>
</v-lazy>
<v-lazy>
<RecipeSuggestion
:recipe="item.recipe"
:missing-foods="item.missingFoods"
:missing-tools="item.missingTools"
:disable-checkbox="loading"
@add-food="addFood"
@remove-food="removeFood"
@add-tool="addTool"
@remove-tool="removeTool"
/>
</v-lazy>
</v-col>
</v-row>
</v-container>
<v-container v-else-if="!recipesReady">
<v-row>
<v-col cols="12" class="d-flex justify-center">
<v-col
cols="12"
class="d-flex justify-center"
>
<div class="text-center">
<AppLoader waiting-text="" />
</div>
@ -287,10 +374,15 @@
</v-container>
<v-container v-else>
<v-row>
<v-col cols="12" class="d-flex flex-row flex-wrap justify-center">
<v-card-title class="ma-0 pa-0">{{ $tc("recipe-finder.no-recipes-found") }}</v-card-title>
<v-col
cols="12"
class="d-flex flex-column justify-center align-center ga-1"
>
<v-card-title class="ma-0 pa-0">
{{ $t("recipe-finder.no-recipes-found") }}
</v-card-title>
<v-card-text class="ma-0 pa-0 text-center">
{{ $tc("recipe-finder.no-recipes-found-description") }}
{{ $t("recipe-finder.no-recipes-found-description") }}
</v-card-text>
</v-col>
</v-row>
@ -300,7 +392,10 @@
</v-container>
<v-container v-else>
<v-row>
<v-col cols="12" class="d-flex justify-center">
<v-col
cols="12"
class="d-flex justify-center"
>
<div class="text-center">
<AppLoader waiting-text="" />
</div>
@ -311,29 +406,18 @@
</template>
<script lang="ts">
import {
computed,
defineComponent,
onMounted,
reactive,
ref,
toRefs,
useContext,
useRoute,
watch
} from "@nuxtjs/composition-api";
import { watchDebounced } from "@vueuse/core";
import { useUserApi } from "~/composables/api";
import { usePublicExploreApi } from "~/composables/api/api-client";
import { useLoggedInState } from "~/composables/use-logged-in-state";
import { useFoodStore, usePublicFoodStore, useToolStore, usePublicToolStore } from "~/composables/store";
import { IngredientFood, RecipeSuggestionQuery, RecipeSuggestionResponseItem, RecipeTool } from "~/lib/api/types/recipe";
import type { IngredientFood, RecipeSuggestionQuery, RecipeSuggestionResponseItem, RecipeTool } from "~/lib/api/types/recipe";
import { Organizer } from "~/lib/api/types/non-generated";
import QueryFilterBuilder from "~/components/Domain/QueryFilterBuilder.vue";
import RecipeSuggestion from "~/components/Domain/Recipe/RecipeSuggestion.vue";
import SearchFilter from "~/components/Domain/SearchFilter.vue";
import { QueryFilterJSON } from "~/lib/api/types/response";
import { FieldDefinition } from "~/composables/use-query-filter-builder";
import type { QueryFilterJSON } from "~/lib/api/types/response";
import type { FieldDefinition } from "~/composables/use-query-filter-builder";
import { useRecipeFinderPreferences } from "~/composables/use-users/preferences";
interface RecipeSuggestions {
@ -341,14 +425,21 @@ interface RecipeSuggestions {
missingItems: RecipeSuggestionResponseItem[];
}
export default defineComponent({
export default defineNuxtComponent({
components: { QueryFilterBuilder, RecipeSuggestion, SearchFilter },
setup() {
const { $auth, $vuetify, i18n } = useContext();
const { $vuetify } = useNuxtApp();
const i18n = useI18n();
const $auth = useMealieAuth();
const route = useRoute();
const useMobile = computed(() => $vuetify.breakpoint.smAndDown);
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
useSeoMeta({
title: i18n.t("recipe-finder.recipe-finder"),
});
const useMobile = computed(() => $vuetify.display.smAndDown.value);
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const { isOwnGroup } = useLoggedInState();
const api = isOwnGroup.value ? useUserApi() : usePublicExploreApi(groupSlug.value).explore;
@ -411,49 +502,49 @@ export default defineComponent({
colClass: useMobile.value ? "d-flex flex-wrap justify-end" : "d-flex flex-wrap justify-start",
},
};
})
});
const foodStore = isOwnGroup.value ? useFoodStore() : usePublicFoodStore(groupSlug.value);
const selectedFoods = ref<IngredientFood[]>([]);
function addFood(food: IngredientFood) {
selectedFoods.value.push(food);
selectedFoods.value = [...selectedFoods.value, food];
handleFoodUpdates();
}
function removeFood(food: IngredientFood) {
selectedFoods.value = selectedFoods.value.filter((f) => f.id !== food.id);
selectedFoods.value = selectedFoods.value.filter(f => f.id !== food.id);
handleFoodUpdates();
}
function handleFoodUpdates() {
selectedFoods.value.sort((a, b) => (a.pluralName || a.name).localeCompare(b.pluralName || b.name));
preferences.value.foodIds = selectedFoods.value.map((food) => food.id);
preferences.value.foodIds = selectedFoods.value.map(food => food.id);
}
watch(
() => selectedFoods.value,
() => {
handleFoodUpdates();
},
)
);
const toolStore = isOwnGroup.value ? useToolStore() : usePublicToolStore(groupSlug.value);
const selectedTools = ref<RecipeTool[]>([]);
function addTool(tool: RecipeTool) {
selectedTools.value.push(tool);
selectedTools.value = [...selectedTools.value, tool];
handleToolUpdates();
}
function removeTool(tool: RecipeTool) {
selectedTools.value = selectedTools.value.filter((t) => t.id !== tool.id);
selectedTools.value = selectedTools.value.filter(t => t.id !== tool.id);
handleToolUpdates();
}
function handleToolUpdates() {
selectedTools.value.sort((a, b) => a.name.localeCompare(b.name));
preferences.value.toolIds = selectedTools.value.map((tool) => tool.id);
preferences.value.toolIds = selectedTools.value.map(tool => tool.id);
}
watch(
() => selectedTools.value,
() => {
handleToolUpdates();
}
)
},
);
async function hydrateFoods() {
if (!preferences.value.foodIds.length) {
@ -464,8 +555,8 @@ export default defineComponent({
}
const foods = preferences.value.foodIds
.map((foodId) => foodStore.store.value.find((food) => food.id === foodId))
.filter((food) => !!food);
.map(foodId => foodStore.store.value.find(food => food.id === foodId))
.filter(food => !!food);
selectedFoods.value = foods;
}
@ -479,8 +570,8 @@ export default defineComponent({
}
const tools = preferences.value.toolIds
.map((toolId) => toolStore.store.value.find((tool) => tool.id === toolId))
.filter((tool) => !!tool);
.map(toolId => toolStore.store.value.find(tool => tool.id === toolId))
.filter(tool => !!tool);
selectedTools.value = tools;
}
@ -500,7 +591,8 @@ export default defineComponent({
recipeResponseItems.value.forEach((responseItem) => {
if (responseItem.missingFoods.length === 0 && responseItem.missingTools.length === 0) {
readyToMake.push(responseItem);
} else {
}
else {
missingItems.push(responseItem);
};
});
@ -509,12 +601,12 @@ export default defineComponent({
readyToMake,
missingItems,
};
})
});
watchDebounced(
[selectedFoods, selectedTools, state.settings], async () => {
// don't search for suggestions if no foods are selected
if(!selectedFoods.value.length) {
if (!selectedFoods.value.length) {
recipeResponseItems.value = [];
state.recipesReady = true;
return;
@ -530,8 +622,8 @@ export default defineComponent({
includeFoodsOnHand: state.settings.includeFoodsOnHand,
includeToolsOnHand: state.settings.includeToolsOnHand,
} as RecipeSuggestionQuery,
selectedFoods.value.map((food) => food.id),
selectedTools.value.map((tool) => tool.id),
selectedFoods.value.map(food => food.id),
selectedTools.value.map(tool => tool.id),
);
state.loading = false;
if (!data) {
@ -548,17 +640,17 @@ export default defineComponent({
const queryFilterBuilderFields: FieldDefinition[] = [
{
name: "recipe_category.id",
label: i18n.tc("category.categories"),
label: i18n.t("category.categories"),
type: Organizer.Category,
},
{
name: "tags.id",
label: i18n.tc("tag.tags"),
label: i18n.t("tag.tags"),
type: Organizer.Tag,
},
{
name: "household_id",
label: i18n.tc("household.households"),
label: i18n.t("household.households"),
type: Organizer.Household,
},
];
@ -597,10 +689,5 @@ export default defineComponent({
saveQueryFilter,
};
},
head() {
return {
title: this.$tc("recipe-finder.recipe-finder"),
};
},
});
</script>

View file

@ -8,33 +8,34 @@
@delete="actions.deleteOne"
@update="actions.updateOne"
>
<template #title> {{ $t("tag.tags") }} </template>
<template #title>
{{ $t("tag.tags") }}
</template>
</RecipeOrganizerPage>
</v-container>
</template>
<script lang="ts">
import { defineComponent } from "@nuxtjs/composition-api";
import RecipeOrganizerPage from "~/components/Domain/Recipe/RecipeOrganizerPage.vue";
import { useTagStore } from "~/composables/store";
export default defineComponent({
export default defineNuxtComponent({
components: {
RecipeOrganizerPage,
},
middleware: ["auth", "group-only"],
middleware: ["sidebase-auth", "group-only"],
setup() {
const { store, actions } = useTagStore();
const i18n = useI18n();
useSeoMeta({
title: i18n.t("tag.tags"),
});
return {
store,
actions,
};
},
head() {
return {
title: this.$tc("tag.tags"),
};
},
});
</script>

View file

@ -0,0 +1,67 @@
<template>
<div>
<BasePageTitle
v-if="groupName"
class="bg-grey-darken-4 mt-n4 pt-8"
>
<template #header>
<v-img
width="100%"
max-height="200"
max-width="150"
:src="require('~/static/svgs/manage-members.svg')"
/>
</template>
<template #title>
{{ $t("recipe.group-global-timeline", { groupName }) }}
</template>
</BasePageTitle>
<v-sheet :class="$vuetify.display.smAndDown ? 'pa-0' : 'px-3 py-0'">
<RecipeTimeline
v-if="queryFilter"
v-model="ready"
show-recipe-cards
:query-filter="queryFilter"
/>
</v-sheet>
</div>
</template>
<script lang="ts">
import { useUserApi } from "~/composables/api";
import RecipeTimeline from "~/components/Domain/Recipe/RecipeTimeline.vue";
export default defineNuxtComponent({
components: { RecipeTimeline },
middleware: ["sidebase-auth", "group-only"],
setup() {
const i18n = useI18n();
const api = useUserApi();
const ready = ref<boolean>(false);
useSeoMeta({
title: i18n.t("recipe.timeline"),
});
const groupName = ref<string>("");
const queryFilter = ref<string>("");
async function fetchHousehold() {
const { data } = await api.households.getCurrentUserHousehold();
if (data) {
queryFilter.value = `recipe.group_id="${data.groupId}"`;
groupName.value = data.group;
}
ready.value = true;
}
useAsyncData("house-hold", fetchHousehold);
return {
groupName,
queryFilter,
ready,
};
},
});
</script>

View file

@ -8,36 +8,42 @@
@delete="deleteOne"
@update="updateOne"
>
<template #title> {{ $t("tool.tools") }} </template>
<template #title>
{{ $t("tool.tools") }}
</template>
</RecipeOrganizerPage>
</v-container>
</template>
<script lang="ts">
import { computed, defineComponent, ref, useContext } from "@nuxtjs/composition-api";
import RecipeOrganizerPage from "~/components/Domain/Recipe/RecipeOrganizerPage.vue";
import { useToolStore } from "~/composables/store";
import { RecipeTool } from "~/lib/api/types/recipe";
import type { RecipeTool } from "~/lib/api/types/recipe";
interface RecipeToolWithOnHand extends RecipeTool {
onHand: boolean;
}
export default defineComponent({
export default defineNuxtComponent({
components: {
RecipeOrganizerPage,
},
middleware: ["auth", "group-only"],
middleware: ["sidebase-auth", "group-only"],
setup() {
const { $auth } = useContext();
const $auth = useMealieAuth();
const toolStore = useToolStore();
const dialog = ref(false);
const i18n = useI18n();
const userHousehold = computed(() => $auth.user?.householdSlug || "");
const tools = computed(() => toolStore.store.value.map((tool) => (
useSeoMeta({
title: i18n.t("tool.tools"),
});
const userHousehold = computed(() => $auth.user.value?.householdSlug || "");
const tools = computed(() => toolStore.store.value.map(tool => (
{
...tool,
onHand: tool.householdsWithTool?.includes(userHousehold.value) || false
onHand: tool.householdsWithTool?.includes(userHousehold.value) || false,
} as RecipeToolWithOnHand
)));
@ -50,11 +56,13 @@ export default defineComponent({
if (tool.onHand && !tool.householdsWithTool?.includes(userHousehold.value)) {
if (!tool.householdsWithTool) {
tool.householdsWithTool = [userHousehold.value];
} else {
}
else {
tool.householdsWithTool.push(userHousehold.value);
}
} else if (!tool.onHand && tool.householdsWithTool?.includes(userHousehold.value)) {
tool.householdsWithTool = tool.householdsWithTool.filter((household) => household !== userHousehold.value);
}
else if (!tool.onHand && tool.householdsWithTool?.includes(userHousehold.value)) {
tool.householdsWithTool = tool.householdsWithTool.filter(household => household !== userHousehold.value);
}
}
await toolStore.actions.updateOne(tool);
@ -67,10 +75,5 @@ export default defineComponent({
updateOne,
};
},
head() {
return {
title: this.$tc("tool.tools"),
};
},
});
</script>

View file

@ -0,0 +1,47 @@
<template>
<div>
<client-only>
<RecipePage
v-if="recipe"
v-model="recipe"
/>
</client-only>
</div>
</template>
<script setup lang="ts">
import RecipePage from "~/components/Domain/Recipe/RecipePage/RecipePage.vue";
import { usePublicApi } from "~/composables/api/api-client";
definePageMeta({
layout: "basic",
});
const $auth = useMealieAuth();
const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug as string || $auth.user.value?.groupSlug || "");
const router = useRouter();
const recipeId = route.params.id as string;
const api = usePublicApi();
const title = ref(route.meta?.title ?? "");
useSeoMeta({
title,
});
const { data: recipe } = await useAsyncData("recipe", async () => {
const { data, error } = await api.shared.getShared(recipeId);
if (error) {
console.error("error loading recipe -> ", error);
router.push(`/g/${groupSlug.value}`);
}
if (data) {
title.value = data?.name || "";
}
return data;
});
</script>

View file

@ -1,232 +0,0 @@
<template>
<div>
<!-- Create Dialog -->
<BaseDialog
v-if="createTarget"
v-model="dialogStates.create"
width="100%"
max-width="1100px"
:icon="$globals.icons.pages"
:title="$t('cookbook.create-a-cookbook')"
:submit-icon="$globals.icons.save"
:submit-text="$tc('general.save')"
:submit-disabled="!createTarget.queryFilterString"
@submit="actions.updateOne(createTarget)"
@cancel="deleteCreateTarget()"
>
<v-card-text>
<CookbookEditor
:key="createTargetKey"
:cookbook=createTarget
:actions="actions"
/>
</v-card-text>
</BaseDialog>
<!-- Delete Dialog -->
<BaseDialog
v-model="dialogStates.delete"
:title="$t('general.delete-with-name', { name: $t('cookbook.cookbook') })"
:icon="$globals.icons.alertCircle"
color="error"
@confirm="deleteCookbook()"
>
<v-card-text>
<p>{{ $t("general.confirm-delete-generic-with-name", { name: $t('cookbook.cookbook') }) }}</p>
<p v-if="deleteTarget" class="mt-4 ml-4">{{ deleteTarget.name }}</p>
</v-card-text>
</BaseDialog>
<!-- Cookbook Page -->
<!-- Page Title -->
<v-container class="px-12">
<BasePageTitle divider>
<template #header>
<v-img max-height="100" max-width="100" :src="require('~/static/svgs/manage-cookbooks.svg')"></v-img>
</template>
<template #title> {{ $t('cookbook.cookbooks') }} </template>
{{ $t('cookbook.description') }}
</BasePageTitle>
<div class="my-6">
<v-checkbox
v-model="cookbookPreferences.hideOtherHouseholds"
:label="$tc('cookbook.hide-cookbooks-from-other-households')"
hide-details
/>
<div class="ml-8">
<p class="text-subtitle-2 my-0 py-0">
{{ $tc("cookbook.hide-cookbooks-from-other-households-description") }}
</p>
</div>
</div>
<!-- Create New -->
<BaseButton create @click="createCookbook" />
<!-- Cookbook List -->
<v-expansion-panels class="mt-2">
<draggable
v-model="myCookbooks"
handle=".handle"
delay="250"
:delay-on-touch-only="true"
style="width: 100%"
@change="actions.updateOrder(myCookbooks)"
>
<v-expansion-panel v-for="cookbook in myCookbooks" :key="cookbook.id" class="my-2 left-border rounded">
<v-expansion-panel-header disable-icon-rotate class="headline">
<div class="d-flex align-center">
<v-icon large left>
{{ $globals.icons.pages }}
</v-icon>
{{ cookbook.name }}
</div>
<template #actions>
<v-icon class="handle">
{{ $globals.icons.arrowUpDown }}
</v-icon>
<v-btn icon small class="ml-2">
<v-icon>
{{ $globals.icons.edit }}
</v-icon>
</v-btn>
</template>
</v-expansion-panel-header>
<v-expansion-panel-content>
<CookbookEditor :cookbook="cookbook" :actions="actions" :collapsable="false" @delete="deleteEventHandler" />
<v-card-actions>
<v-spacer></v-spacer>
<BaseButtonGroup
:buttons="[{
icon: $globals.icons.delete,
text: $tc('general.delete'),
event: 'delete',
},
{
icon: $globals.icons.save,
text: $tc('general.save'),
event: 'save',
disabled: !cookbook.queryFilterString
},
]"
@delete="deleteEventHandler(cookbook)"
@save="actions.updateOne(cookbook)" />
</v-card-actions>
</v-expansion-panel-content>
</v-expansion-panel>
</draggable>
</v-expansion-panels>
</v-container>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, onBeforeUnmount, onMounted, reactive, ref, useContext } from "@nuxtjs/composition-api";
import draggable from "vuedraggable";
import { useCookbooks } from "@/composables/use-group-cookbooks";
import { useHouseholdSelf } from "@/composables/use-households";
import CookbookEditor from "~/components/Domain/Cookbook/CookbookEditor.vue";
import { ReadCookBook } from "~/lib/api/types/cookbook";
import { useCookbookPreferences } from "~/composables/use-users/preferences";
export default defineComponent({
components: { CookbookEditor, draggable },
middleware: ["auth", "group-only"],
setup() {
const dialogStates = reactive({
create: false,
delete: false,
});
const { $auth, i18n } = useContext();
const { cookbooks: allCookbooks, actions } = useCookbooks();
const myCookbooks = computed<ReadCookBook[]>({
get: () => {
return allCookbooks.value?.filter((cookbook) => {
return cookbook.householdId === $auth.user?.householdId;
}) || [];
},
set: (value: ReadCookBook[]) => {
actions.updateOrder(value);
},
});
const { household } = useHouseholdSelf();
const cookbookPreferences = useCookbookPreferences()
// create
const createTargetKey = ref(0);
const createTarget = ref<ReadCookBook | null>(null);
async function createCookbook() {
const name = i18n.t("cookbook.household-cookbook-name", [household.value?.name || "", String((myCookbooks.value?.length ?? 0) + 1)]) as string
await actions.createOne(name).then((cookbook) => {
createTarget.value = cookbook as ReadCookBook;
createTargetKey.value++;
});
dialogStates.create = true;
}
// delete
const deleteTarget = ref<ReadCookBook | null>(null);
function deleteEventHandler(item: ReadCookBook){
deleteTarget.value = item;
dialogStates.delete = true;
}
function deleteCookbook() {
if (!deleteTarget.value) {
return;
}
actions.deleteOne(deleteTarget.value.id);
dialogStates.delete = false;
deleteTarget.value = null;
}
function deleteCreateTarget() {
if (!createTarget.value?.id) {
return;
}
actions.deleteOne(createTarget.value.id);
dialogStates.create = false;
createTarget.value = null;
}
function handleUnmount() {
if(!createTarget.value?.id || createTarget.value.queryFilterString) {
return;
}
deleteCreateTarget();
}
onMounted(() => {
window.addEventListener("beforeunload", handleUnmount);
});
onBeforeUnmount(() => {
handleUnmount();
window.removeEventListener("beforeunload", handleUnmount);
});
return {
myCookbooks,
cookbookPreferences,
actions,
dialogStates,
// create
createTargetKey,
createTarget,
createCookbook,
// delete
deleteTarget,
deleteEventHandler,
deleteCookbook,
deleteCreateTarget,
};
},
head() {
return {
title: this.$t("cookbook.cookbooks") as string,
};
},
});
</script>

View file

@ -1,60 +0,0 @@
<template>
<div>
<RecipePage v-if="recipe" :recipe="recipe" />
</div>
</template>
<script lang="ts">
import { computed, defineComponent, ref, useAsync, useContext, useMeta, useRoute, useRouter } from "@nuxtjs/composition-api";
import { whenever } from "@vueuse/core";
import { useLoggedInState } from "~/composables/use-logged-in-state";
import { useAsyncKey } from "~/composables/use-utils";
import RecipePage from "~/components/Domain/Recipe/RecipePage/RecipePage.vue";
import { usePublicExploreApi } from "~/composables/api/api-client";
import { useRecipe } from "~/composables/recipes";
import { Recipe } from "~/lib/api/types/recipe";
export default defineComponent({
components: { RecipePage },
setup() {
const { $auth } = useContext();
const { isOwnGroup } = useLoggedInState();
const { title } = useMeta();
const route = useRoute();
const router = useRouter();
const slug = route.value.params.slug;
let recipe = ref<Recipe | null>(null);
if (isOwnGroup.value) {
const { recipe: data } = useRecipe(slug);
recipe = data;
} else {
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "")
const api = usePublicExploreApi(groupSlug.value);
recipe = useAsync(async () => {
const { data, error } = await api.explore.recipes.getOne(slug);
if (error) {
console.error("error loading recipe -> ", error);
router.push(`/g/${groupSlug.value}`);
}
return data;
}, useAsyncKey())
}
whenever(
() => recipe.value,
() => {
if (recipe.value) {
title.value = recipe.value.name;
}
},
)
return {
recipe,
};
},
head: {},
});
</script>

View file

@ -1,50 +0,0 @@
<template>
<v-sheet :class="$vuetify.breakpoint.smAndDown ? 'pa-0' : 'px-3 py-0'">
<BasePageTitle v-if="groupName">
<template #header>
<v-img max-height="200" max-width="150" :src="require('~/static/svgs/manage-members.svg')" />
</template>
<template #title> {{ $t("recipe.group-global-timeline", { groupName }) }} </template>
</BasePageTitle>
<RecipeTimeline v-if="queryFilter" v-model="ready" show-recipe-cards :query-filter="queryFilter" />
</v-sheet>
</template>
<script lang="ts">
import { defineComponent, ref } from "@nuxtjs/composition-api";
import { useUserApi } from "~/composables/api";
import RecipeTimeline from "~/components/Domain/Recipe/RecipeTimeline.vue";
export default defineComponent({
components: { RecipeTimeline },
middleware: ["auth", "group-only"],
setup() {
const api = useUserApi();
const ready = ref<boolean>(false);
const groupName = ref<string>("");
const queryFilter = ref<string>("");
async function fetchHousehold() {
const { data } = await api.households.getCurrentUserHousehold();
if (data) {
queryFilter.value = `recipe.group_id="${data.groupId}"`;
groupName.value = data.group;
}
ready.value = true;
}
fetchHousehold();
return {
groupName,
queryFilter,
ready,
};
},
head() {
return {
title: this.$t("recipe.timeline") as string,
};
},
});
</script>

View file

@ -1,49 +0,0 @@
<template>
<div>
<client-only>
<RecipePage v-if="recipe" :recipe="recipe" />
</client-only>
</div>
</template>
<script lang="ts">
import { computed, defineComponent, useAsync, useContext, useMeta, useRoute, useRouter } from "@nuxtjs/composition-api";
import RecipePage from "~/components/Domain/Recipe/RecipePage/RecipePage.vue";
import { usePublicApi } from "~/composables/api/api-client";
export default defineComponent({
components: { RecipePage },
layout: "basic",
setup() {
const { $auth } = useContext();
const route = useRoute();
const groupSlug = computed(() => route.value.params.groupSlug || $auth.user?.groupSlug || "");
const router = useRouter();
const recipeId = route.value.params.id;
const api = usePublicApi();
const { title } = useMeta();
const recipe = useAsync(async () => {
const { data, error } = await api.shared.getShared(recipeId);
if (error) {
console.error("error loading recipe -> ", error);
router.push(`/g/${groupSlug.value}`);
}
if (data) {
title.value = data?.name || "";
}
return data;
});
return {
recipe,
};
},
head: {},
});
</script>