From 3882648dbf01283eb33449ea3b336752de9a019c Mon Sep 17 00:00:00 2001 From: hay-kot Date: Tue, 27 Apr 2021 18:33:06 -0800 Subject: [PATCH] recipe instructions section --- .../RecipeEditor/InstructionsEditor.vue | 149 ++++++++++++++++++ .../components/Recipe/RecipeEditor/index.vue | 41 +---- .../components/Recipe/RecipeViewer/Steps.vue | 67 -------- .../components/Recipe/RecipeViewer/index.vue | 6 +- mealie/db/models/recipe/instruction.py | 1 + mealie/db/models/recipe/recipe.py | 2 +- mealie/schema/recipe.py | 1 + 7 files changed, 162 insertions(+), 105 deletions(-) create mode 100644 frontend/src/components/Recipe/RecipeEditor/InstructionsEditor.vue delete mode 100644 frontend/src/components/Recipe/RecipeViewer/Steps.vue diff --git a/frontend/src/components/Recipe/RecipeEditor/InstructionsEditor.vue b/frontend/src/components/Recipe/RecipeEditor/InstructionsEditor.vue new file mode 100644 index 000000000..37c3dbea7 --- /dev/null +++ b/frontend/src/components/Recipe/RecipeEditor/InstructionsEditor.vue @@ -0,0 +1,149 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipeEditor/index.vue b/frontend/src/components/Recipe/RecipeEditor/index.vue index 5925a53a8..1d059f41f 100644 --- a/frontend/src/components/Recipe/RecipeEditor/index.vue +++ b/frontend/src/components/Recipe/RecipeEditor/index.vue @@ -175,40 +175,7 @@ -

{{ $t("recipe.instructions") }}

-
- - - - - mdi-delete - - {{ $t("recipe.step-index", { step: index + 1 }) }} - - - - - - - -
+
@@ -237,6 +204,7 @@ import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector"; import NutritionEditor from "./NutritionEditor"; import ImageUploadBtn from "./ImageUploadBtn.vue"; import { validators } from "@/mixins/validators"; +import InstructionsEditor from "./InstructionsEditor.vue"; export default { components: { BulkAdd, @@ -245,6 +213,7 @@ export default { CategoryTagSelector, NutritionEditor, ImageUploadBtn, + InstructionsEditor, }, props: { value: Object, @@ -254,9 +223,13 @@ export default { return { drag: false, fileObject: null, + lastTitleIndex: 0, }; }, methods: { + validateTitle(title) { + return !(title === null || title === ""); + }, uploadImage(fileObject) { this.$emit(UPLOAD_EVENT, fileObject); }, diff --git a/frontend/src/components/Recipe/RecipeViewer/Steps.vue b/frontend/src/components/Recipe/RecipeViewer/Steps.vue deleted file mode 100644 index 4b674668e..000000000 --- a/frontend/src/components/Recipe/RecipeViewer/Steps.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - - - \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipeViewer/index.vue b/frontend/src/components/Recipe/RecipeViewer/index.vue index 813a8d5ab..4cfa3925e 100644 --- a/frontend/src/components/Recipe/RecipeViewer/index.vue +++ b/frontend/src/components/Recipe/RecipeViewer/index.vue @@ -50,7 +50,7 @@ > - +
@@ -86,17 +86,17 @@ import NutritionEditor from "@/components/Recipe/RecipeEditor/NutritionEditor"; import VueMarkdown from "@adapttive/vue-markdown"; import utils from "@/utils"; import RecipeChips from "./RecipeChips"; -import Steps from "./Steps"; import Notes from "./Notes"; import Ingredients from "./Ingredients"; +import InstructionsEditor from "../RecipeEditor/InstructionsEditor.vue"; export default { components: { VueMarkdown, RecipeChips, - Steps, Notes, Ingredients, NutritionEditor, + InstructionsEditor, }, props: { name: String, diff --git a/mealie/db/models/recipe/instruction.py b/mealie/db/models/recipe/instruction.py index 2cb2e38a6..5aa136ea5 100644 --- a/mealie/db/models/recipe/instruction.py +++ b/mealie/db/models/recipe/instruction.py @@ -9,3 +9,4 @@ class RecipeInstruction(SqlAlchemyBase): position = sa.Column(sa.Integer) type = sa.Column(sa.String, default="") text = sa.Column(sa.String) + title = sa.Column(sa.String) diff --git a/mealie/db/models/recipe/recipe.py b/mealie/db/models/recipe/recipe.py index 3127a840b..687b51c01 100644 --- a/mealie/db/models/recipe/recipe.py +++ b/mealie/db/models/recipe/recipe.py @@ -100,7 +100,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins): self.recipeYield = recipeYield self.recipeIngredient = [RecipeIngredient(ingredient=ingr) for ingr in recipeIngredient] self.recipeInstructions = [ - RecipeInstruction(text=instruc.get("text"), type=instruc.get("@type", None)) + RecipeInstruction(text=instruc.get("text"), title=instruc.get("title"), type=instruc.get("@type", None)) for instruc in recipeInstructions ] self.totalTime = totalTime diff --git a/mealie/schema/recipe.py b/mealie/schema/recipe.py index 994255a4b..fd42a4f2c 100644 --- a/mealie/schema/recipe.py +++ b/mealie/schema/recipe.py @@ -16,6 +16,7 @@ class RecipeNote(BaseModel): class RecipeStep(BaseModel): + title: Optional[str] = "" text: str class Config: