diff --git a/frontend/composables/use-new-recipe-options.ts b/frontend/composables/use-new-recipe-options.ts index 0788cf0eb..6f01c2b5b 100644 --- a/frontend/composables/use-new-recipe-options.ts +++ b/frontend/composables/use-new-recipe-options.ts @@ -2,6 +2,7 @@ import { useRecipeCreatePreferences } from "~/composables/use-users/preferences" export interface UseNewRecipeOptionsProps { enableImportKeywords?: boolean; + enableImportCategories?: boolean; enableStayInEditMode?: boolean; enableParseRecipe?: boolean; } @@ -9,6 +10,7 @@ export interface UseNewRecipeOptionsProps { export function useNewRecipeOptions(props: UseNewRecipeOptionsProps = {}) { const { enableImportKeywords = true, + enableImportCategories = true, enableStayInEditMode = true, enableParseRecipe = true, } = props; @@ -27,6 +29,17 @@ export function useNewRecipeOptions(props: UseNewRecipeOptionsProps = {}) { }, }); + const importCategories = computed({ + get() { + if (!enableImportCategories) return false; + return recipeCreatePreferences.value.importCategories; + }, + set(v: boolean) { + if (!enableImportCategories) return; + recipeCreatePreferences.value.importCategories = v; + }, + }); + const stayInEditMode = computed({ get() { if (!enableStayInEditMode) return false; @@ -71,6 +84,7 @@ export function useNewRecipeOptions(props: UseNewRecipeOptionsProps = {}) { return { // Computed properties for the checkboxes importKeywordsAsTags, + importCategories, stayInEditMode, parseRecipe, @@ -79,6 +93,7 @@ export function useNewRecipeOptions(props: UseNewRecipeOptionsProps = {}) { // Props for conditional rendering enableImportKeywords, + enableImportCategories, enableStayInEditMode, enableParseRecipe, }; diff --git a/frontend/composables/use-users/preferences.ts b/frontend/composables/use-users/preferences.ts index 46f4752b0..103678788 100644 --- a/frontend/composables/use-users/preferences.ts +++ b/frontend/composables/use-users/preferences.ts @@ -63,6 +63,7 @@ export interface UserRecipeFinderPreferences { export interface UserRecipeCreatePreferences { importKeywordsAsTags: boolean; + importCategories: boolean; stayInEditMode: boolean; parseRecipe: boolean; } @@ -233,6 +234,7 @@ export function useRecipeCreatePreferences(): Ref { "recipe-create-preferences", { importKeywordsAsTags: false, + importCategories: false, stayInEditMode: false, parseRecipe: true, }, diff --git a/frontend/lang/messages/en-US.json b/frontend/lang/messages/en-US.json index 9e67a2adc..43d3b82e0 100644 --- a/frontend/lang/messages/en-US.json +++ b/frontend/lang/messages/en-US.json @@ -642,6 +642,7 @@ "scrape-recipe-website-being-blocked": "Website being blocked?", "scrape-recipe-try-importing-raw-html-instead": "Try importing the raw HTML instead.", "import-original-keywords-as-tags": "Import original keywords as tags", + "import-original-categories": "Import original categories", "stay-in-edit-mode": "Stay in Edit mode", "parse-recipe-ingredients-after-import": "Parse recipe ingredients after import", "import-from-zip": "Import from Zip", diff --git a/frontend/lib/api/user/recipes/recipe.ts b/frontend/lib/api/user/recipes/recipe.ts index bc56a9591..abf398631 100644 --- a/frontend/lib/api/user/recipes/recipe.ts +++ b/frontend/lib/api/user/recipes/recipe.ts @@ -146,12 +146,12 @@ export class RecipeAPI extends BaseCRUDAPI { return await this.requests.post(routes.recipesTestScrapeUrl, { url, useOpenAI }); } - async createOneByHtmlOrJson(data: string, includeTags: boolean, url: string | null = null) { - return await this.requests.post(routes.recipesCreateFromHtmlOrJson, { data, includeTags, url }); + async createOneByHtmlOrJson(data: string, includeTags: boolean, includeCategories: boolean, url: string | null = null) { + return await this.requests.post(routes.recipesCreateFromHtmlOrJson, { data, includeTags, includeCategories, url }); } - async createOneByUrl(url: string, includeTags: boolean) { - return await this.requests.post(routes.recipesCreateUrl, { url, includeTags }); + async createOneByUrl(url: string, includeTags: boolean, includeCategories: boolean) { + return await this.requests.post(routes.recipesCreateUrl, { url, includeTags, includeCategories }); } async createManyByUrl(payload: CreateRecipeByUrlBulk) { diff --git a/frontend/pages/g/[groupSlug]/r/create/html.vue b/frontend/pages/g/[groupSlug]/r/create/html.vue index 5e0eccc5c..e358c7d42 100644 --- a/frontend/pages/g/[groupSlug]/r/create/html.vue +++ b/frontend/pages/g/[groupSlug]/r/create/html.vue @@ -1,7 +1,7 @@