From 7a48b659f812e983245ff51b94bf498adb599a70 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Tue, 27 Apr 2021 09:53:55 -0800 Subject: [PATCH] recipe store refactor --- .gitignore | 4 +- frontend/src/api/recipe.js | 6 +- .../src/components/MealPlan/MealPlanNew.vue | 5 +- .../src/components/UI/Search/SearchBar.vue | 2 +- .../ToolBox/CategoryTagEditor/BulkAssign.vue | 2 +- frontend/src/pages/HomePage.vue | 4 +- frontend/src/pages/Recipes/AllRecipes.vue | 19 ++++- frontend/src/pages/SearchPage/index.vue | 2 +- frontend/src/store/index.js | 18 +---- frontend/src/store/modules/recipes.js | 73 +++++++++++++++++++ mealie/db/models/recipe/recipe.py | 4 + mealie/routes/recipe/recipe_crud_routes.py | 2 +- mealie/schema/recipe.py | 1 + 13 files changed, 110 insertions(+), 32 deletions(-) create mode 100644 frontend/src/store/modules/recipes.js diff --git a/.gitignore b/.gitignore index d01991ff2..e6097687d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ mealie/temp/* mealie/temp/api.html .temp/ .secret - +*.zip dev/data/backups/* dev/data/debug/* @@ -193,3 +193,5 @@ frontend/dist/js/app.36f2760c.js frontend/dist/js/app.36f2760c.js.map frontend/dist/js/chunk-vendors.c93761e4.js frontend/dist/js/chunk-vendors.c93761e4.js.map +dev/data/backups/dev_sample_data_2021-Apr-25.zip +dev/data/backups/dev_sample_data_2021-Feb-13.zip diff --git a/frontend/src/api/recipe.js b/frontend/src/api/recipe.js index 364d6a688..7ef5489ea 100644 --- a/frontend/src/api/recipe.js +++ b/frontend/src/api/recipe.js @@ -67,13 +67,13 @@ export const recipeAPI = { async update(data) { let response = await apiReq.put(recipeURLs.update(data.slug), data); - store.dispatch("requestRecentRecipes"); - return response.data; + store.dispatch("patchRecipe", response.data); + return response.data.slug; // ! Temporary until I rewrite to refresh page without additional request }, async patch(data) { let response = await apiReq.patch(recipeURLs.update(data.slug), data); - store.dispatch("requestRecentRecipes"); + store.dispatch("patchRecipe", response.data); return response.data; }, diff --git a/frontend/src/components/MealPlan/MealPlanNew.vue b/frontend/src/components/MealPlan/MealPlanNew.vue index 29487c65e..5bdd403f9 100644 --- a/frontend/src/components/MealPlan/MealPlanNew.vue +++ b/frontend/src/components/MealPlan/MealPlanNew.vue @@ -3,7 +3,8 @@ {{ $t("meal-plan.create-a-new-meal-plan") }} - mdi-calendar-minus {{$t('meal-plan.quick-week')}} + mdi-calendar-minus + {{ $t("meal-plan.quick-week") }} @@ -153,7 +154,7 @@ export default { return recipes.length > 0 ? recipes : this.items; }, allRecipes() { - return this.$store.getters.getRecentRecipes; + return this.$store.getters.getAllRecipes; }, }, diff --git a/frontend/src/components/UI/Search/SearchBar.vue b/frontend/src/components/UI/Search/SearchBar.vue index afb7540d0..964fa72a0 100644 --- a/frontend/src/components/UI/Search/SearchBar.vue +++ b/frontend/src/components/UI/Search/SearchBar.vue @@ -132,7 +132,7 @@ export default { }, computed: { data() { - return this.$store.getters.getRecentRecipes; + return this.$store.getters.getAllRecipes; }, autoResults() { return this.fuseResults.length > 1 ? this.fuseResults : this.results; diff --git a/frontend/src/pages/Admin/ToolBox/CategoryTagEditor/BulkAssign.vue b/frontend/src/pages/Admin/ToolBox/CategoryTagEditor/BulkAssign.vue index ea66fadd8..3350806c5 100644 --- a/frontend/src/pages/Admin/ToolBox/CategoryTagEditor/BulkAssign.vue +++ b/frontend/src/pages/Admin/ToolBox/CategoryTagEditor/BulkAssign.vue @@ -94,7 +94,7 @@ export default { }, computed: { allRecipes() { - return this.$store.getters.getRecentRecipes; + return this.$store.getters.getAllRecipes; }, // results() { // if (this.search === null || this.search === "") { diff --git a/frontend/src/pages/HomePage.vue b/frontend/src/pages/HomePage.vue index f44888452..1aaab2c2b 100644 --- a/frontend/src/pages/HomePage.vue +++ b/frontend/src/pages/HomePage.vue @@ -38,8 +38,8 @@ export default { return this.$store.getters.getSiteSettings; }, recentRecipes() { - let recipes = this.$store.getters.getRecentRecipes; - return recipes.sort((a, b) => (a.dateAdded > b.dateAdded ? -1 : 1)); + return this.$store.getters.getRecentRecipes; + }, }, async mounted() { diff --git a/frontend/src/pages/Recipes/AllRecipes.vue b/frontend/src/pages/Recipes/AllRecipes.vue index ebcf39eae..e516f623c 100644 --- a/frontend/src/pages/Recipes/AllRecipes.vue +++ b/frontend/src/pages/Recipes/AllRecipes.vue @@ -1,5 +1,10 @@