mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 20:28:46 -05:00
fixed review shopping before save, improved meal plan edit modal independece
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-modal :id="modal_id" size="lg" :title="modal_title" hide-footer aria-label="" @show="showModal">
|
||||
<div class="row">
|
||||
<div class="row" v-if="entryEditing !== null">
|
||||
<div class="col col-md-12">
|
||||
<div class="row">
|
||||
<div class="col col-md-12">
|
||||
@@ -125,7 +125,7 @@
|
||||
</b-modal>
|
||||
|
||||
<shopping-modal :recipe="last_created_plan.recipe" :servings="last_created_plan.servings" :modal_id="999999"
|
||||
:mealplan="undefined" v-if="last_created_plan !== null && last_created_plan.recipe !== null"/>
|
||||
:mealplan="last_created_plan" v-if="last_created_plan !== null && last_created_plan.recipe !== null"/>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
@@ -152,7 +152,7 @@ export default {
|
||||
name: "MealPlanEditModal",
|
||||
props: {
|
||||
entry: Object,
|
||||
entryEditing_initial_servings: Number,
|
||||
create_date: String,
|
||||
modal_title: String,
|
||||
modal_id: {
|
||||
type: String,
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
entryEditing: {},
|
||||
entryEditing: null,
|
||||
missing_recipe: false,
|
||||
missing_meal_type: false,
|
||||
default_plan_share: [],
|
||||
@@ -186,10 +186,6 @@ export default {
|
||||
entry: {
|
||||
handler() {
|
||||
this.entryEditing = Object.assign({}, this.entry)
|
||||
|
||||
if (this.entryEditing_initial_servings) {
|
||||
this.entryEditing.servings = this.entryEditing_initial_servings
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
@@ -204,9 +200,6 @@ export default {
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
entryEditing_initial_servings: function (newVal) {
|
||||
this.entryEditing.servings = newVal
|
||||
},
|
||||
},
|
||||
mounted: function () {
|
||||
useUserPreferenceStore().updateIfStaleOrEmpty()
|
||||
@@ -222,8 +215,18 @@ export default {
|
||||
this.mealplan_settings = Object.assign({}, this.mealplan_settings, this.$cookies.get(MEALPLAN_COOKIE_NAME))
|
||||
}
|
||||
|
||||
if (this.entry === null) {
|
||||
this.entryEditing = useMealPlanStore().empty_meal_plan
|
||||
} else {
|
||||
this.entryEditing = this.entry
|
||||
}
|
||||
|
||||
if (this.create_date) {
|
||||
this.entryEditing.date = this.create_date
|
||||
}
|
||||
|
||||
useUserPreferenceStore().getData().then(userPreference => {
|
||||
if (this.entry.id === -1) {
|
||||
if (this.entryEditing.id === -1) {
|
||||
this.entryEditing.shared = userPreference.plan_share
|
||||
}
|
||||
})
|
||||
@@ -248,9 +251,10 @@ export default {
|
||||
this.last_created_plan = r.data
|
||||
if (r.data.recipe && (this.mealplan_settings.addshopping || this.autoMealPlan) && this.mealplan_settings.reviewshopping) {
|
||||
console.log('OPENING SHOPPING MODAL', this.$bvModal)
|
||||
this.$bvModal.show(`shopping_999999`)
|
||||
this.$nextTick(function () {
|
||||
this.$bvModal.show(`shopping_999999`)
|
||||
})
|
||||
}
|
||||
//TODO cleanout entry editing without breaking default function from meal plan
|
||||
})
|
||||
} else {
|
||||
console.log('CALLING UPDATE')
|
||||
|
||||
@@ -78,6 +78,7 @@ const {ApiApiFactory} = require("@/utils/openapi/api")
|
||||
import {StandardToasts} from "@/utils/utils"
|
||||
import IngredientComponent from "@/components/IngredientComponent"
|
||||
import LoadingSpinner from "@/components/LoadingSpinner"
|
||||
import {useMealPlanStore} from "@/stores/MealPlanStore";
|
||||
// import CustomInputSpinButton from "@/components/CustomInputSpinButton"
|
||||
|
||||
export default {
|
||||
@@ -88,7 +89,7 @@ export default {
|
||||
recipe: {required: true, type: Object},
|
||||
servings: {type: Number, default: undefined},
|
||||
modal_id: {required: true, type: Number},
|
||||
mealplan: {type: Number, default: undefined},
|
||||
mealplan: {type: Object, default: undefined},
|
||||
list_recipe: {type: Number, default: undefined},
|
||||
},
|
||||
data() {
|
||||
@@ -169,6 +170,9 @@ export default {
|
||||
.then((result) => {
|
||||
StandardToasts.makeStandardToast(this, StandardToasts.SUCCESS_CREATE)
|
||||
this.$emit("finish")
|
||||
if (this.mealplan !== undefined && this.mealplan !== null){
|
||||
useMealPlanStore().plans[this.mealplan.id].shopping = true
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_CREATE, err)
|
||||
|
||||
Reference in New Issue
Block a user