diff --git a/.gitignore b/.gitignore index 3b2646bfc..b0c415482 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,4 @@ scratch.py dev/data/backups/dev_sample_data*.zip dev/data/backups/dev_sample_data*.zip !dev/data/backups/test*.zip +dev/data/recipes/* diff --git a/frontend/src/api/recipe.js b/frontend/src/api/recipe.js index 7ef5489ea..3dd8c1a6f 100644 --- a/frontend/src/api/recipe.js +++ b/frontend/src/api/recipe.js @@ -16,6 +16,7 @@ const recipeURLs = { delete: slug => prefix + slug, recipeImage: slug => `${prefix}${slug}/image`, updateImage: slug => `${prefix}${slug}/image`, + createAsset: slug => `${prefix}${slug}/asset`, }; export const recipeAPI = { @@ -60,12 +61,23 @@ export const recipeAPI = { return response; }, + async createAsset(recipeSlug, fileObject, name, icon) { + const fd = new FormData(); + fd.append("file", fileObject); + fd.append("extension", fileObject.name.split(".").pop()); + fd.append("name", name); + fd.append("icon", icon); + let response = apiReq.post(recipeURLs.createAsset(recipeSlug), fd); + return response; + }, + async updateImagebyURL(slug, url) { const response = apiReq.post(recipeURLs.updateImage(slug), { url: url }); return response; }, async update(data) { + console.log(data) let response = await apiReq.put(recipeURLs.update(data.slug), data); store.dispatch("patchRecipe", response.data); return response.data.slug; // ! Temporary until I rewrite to refresh page without additional request diff --git a/frontend/src/components/Recipe/RecipeEditor/BulkAdd.vue b/frontend/src/components/Recipe/RecipeEditor/BulkAdd.vue deleted file mode 100644 index 72439417f..000000000 --- a/frontend/src/components/Recipe/RecipeEditor/BulkAdd.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipeEditor/ExtrasEditor.vue b/frontend/src/components/Recipe/RecipeEditor/ExtrasEditor.vue deleted file mode 100644 index 6acf9165b..000000000 --- a/frontend/src/components/Recipe/RecipeEditor/ExtrasEditor.vue +++ /dev/null @@ -1,104 +0,0 @@ - - - - - \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipeEditor/ImageUploadBtn.vue b/frontend/src/components/Recipe/RecipeEditor/ImageUploadBtn.vue deleted file mode 100644 index b1d543201..000000000 --- a/frontend/src/components/Recipe/RecipeEditor/ImageUploadBtn.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - - - diff --git a/frontend/src/components/Recipe/RecipeEditor/NutritionEditor.vue b/frontend/src/components/Recipe/RecipeEditor/NutritionEditor.vue deleted file mode 100644 index 7050b3250..000000000 --- a/frontend/src/components/Recipe/RecipeEditor/NutritionEditor.vue +++ /dev/null @@ -1,81 +0,0 @@ - - - - - \ 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 0f9c20f7b..b8b894d78 100644 --- a/frontend/src/components/Recipe/RecipeEditor/index.vue +++ b/frontend/src/components/Recipe/RecipeEditor/index.vue @@ -3,7 +3,7 @@ -

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

- - -
- - - - mdi-delete - - - -
-
-
- - - mdi-plus - - +

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

- -

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

- - - - - mdi-delete - - - - - - - - - - mdi-plus - - + +
-

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

-
- - - - - mdi-delete - - {{ $t("recipe.step-index", { step: index + 1 }) }} - - - - - - - + +
+ + + mdi-plus +
- - mdi-plus - - + + const UPLOAD_EVENT = "upload"; -import draggable from "vuedraggable"; -import utils from "@/utils"; -import BulkAdd from "./BulkAdd"; -import ExtrasEditor from "./ExtrasEditor"; +import BulkAdd from "@/components/Recipe/Parts/Helpers/BulkAdd"; +import ExtrasEditor from "@/components/Recipe/Parts/Helpers/ExtrasEditor"; import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector"; -import NutritionEditor from "./NutritionEditor"; -import ImageUploadBtn from "./ImageUploadBtn.vue"; +import ImageUploadBtn from "@/components/Recipe/Parts/Helpers/ImageUploadBtn"; import { validators } from "@/mixins/validators"; +import Nutrition from "@/components/Recipe/Parts/Nutrition"; +import Instructions from "@/components/Recipe/Parts/Instructions"; +import Ingredients from "@/components/Recipe/Parts/Ingredients"; +import Assets from "@/components/Recipe/Parts/Assets.vue"; +import Notes from "@/components/Recipe/Parts/Notes.vue"; export default { components: { BulkAdd, ExtrasEditor, - draggable, CategoryTagSelector, - NutritionEditor, + Nutrition, ImageUploadBtn, + Instructions, + Ingredients, + Assets, + Notes, }, props: { value: Object, @@ -242,7 +140,6 @@ export default { mixins: [validators], data() { return { - drag: false, fileObject: null, }; }, @@ -250,30 +147,6 @@ export default { uploadImage(fileObject) { this.$emit(UPLOAD_EVENT, fileObject); }, - toggleDisabled(stepIndex) { - if (this.disabledSteps.includes(stepIndex)) { - const index = this.disabledSteps.indexOf(stepIndex); - if (index !== -1) { - this.disabledSteps.splice(index, 1); - } - } else { - this.disabledSteps.push(stepIndex); - } - }, - isDisabled(stepIndex) { - return this.disabledSteps.includes(stepIndex) ? "disabled-card" : null; - }, - generateKey(item, index) { - return utils.generateUniqueKey(item, index); - }, - addIngredient(ingredients = null) { - if (ingredients) { - this.value.recipeIngredient.push(...ingredients); - } else { - this.value.recipeIngredient.push(""); - } - }, - appendSteps(steps) { this.value.recipeInstructions.push( ...steps.map(x => ({ @@ -284,15 +157,9 @@ export default { addStep() { this.value.recipeInstructions.push({ text: "" }); }, - addNote() { - this.value.notes.push({ text: "" }); - }, saveExtras(extras) { this.value.extras = extras; }, - removeByIndex(list, index) { - list.splice(index, 1); - }, validateRecipe() { return this.$refs.form.validate(); }, diff --git a/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue b/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue deleted file mode 100644 index c3bec8215..000000000 --- a/frontend/src/components/Recipe/RecipeViewer/Ingredients.vue +++ /dev/null @@ -1,62 +0,0 @@ - - - - - \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipeViewer/Notes.vue b/frontend/src/components/Recipe/RecipeViewer/Notes.vue deleted file mode 100644 index e25701d27..000000000 --- a/frontend/src/components/Recipe/RecipeViewer/Notes.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - - - \ No newline at end of file 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..da878c8d9 100644 --- a/frontend/src/components/Recipe/RecipeViewer/index.vue +++ b/frontend/src/components/Recipe/RecipeViewer/index.vue @@ -31,16 +31,30 @@ - +
- - - - + + + {{ $t("recipe.categories") }} + + + + + + + + + {{ $t("recipe.tags") }} + + + + + + + + +
- + +
- - + +
@@ -82,24 +97,27 @@