diff --git a/vue/src/apps/MealPlanView/MealPlanView.vue b/vue/src/apps/MealPlanView/MealPlanView.vue
index 7652c4bd..c0d027a5 100644
--- a/vue/src/apps/MealPlanView/MealPlanView.vue
+++ b/vue/src/apps/MealPlanView/MealPlanView.vue
@@ -290,6 +290,9 @@
+
{{ $t("Export_To_ICal") }}
@@ -302,11 +305,7 @@
{{ $t("Create") }}
-
-
-
+
@@ -677,53 +676,59 @@ export default {
this.$bvModal.show(`id_meal_plan_edit_modal`)
})
- }
+ },
createAutoPlan() {
this.$bvModal.show(`autoplan-modal`)
},
- async autoPlanThread(date,dateOffset,meal_type,keywords,servings,mealTypesKey){
+ async autoPlanThread(date, dateOffset, meal_type, keywords, servings, mealTypesKey) {
- let apiClient = new ApiApiFactory()
- let currentEntry = Object.assign({}, this.options.entryEditing)
- currentEntry.date = moment(date).add(dateOffset,"d").format("YYYY-MM-DD")
- currentEntry.servings = servings
- await Promise.all([
- currentEntry.recipe = await this.randomRecipe(keywords[mealTypesKey]).then((result)=>{return result}),
- currentEntry.shared = await apiClient.listUserPreferences().then((result) => {return result.data[0].plan_share}),
- currentEntry.meal_type = await this.getMealType(meal_type[mealTypesKey].id).then((result)=>{return result})
- ])
- currentEntry.title = currentEntry.recipe.name
- this.createEntry(currentEntry)
- },
- doAutoPlan(autoPlan){
- let dayInMilliseconds = (86400000)
- let numberOfDays = ((autoPlan.endDay - autoPlan.startDay)/dayInMilliseconds) + 1
+ let apiClient = new ApiApiFactory()
+ let currentEntry = Object.assign({}, this.options.entryEditing)
+ currentEntry.date = moment(date).add(dateOffset, "d").format("YYYY-MM-DD")
+ currentEntry.servings = servings
+ await Promise.all([
+ currentEntry.recipe = await this.randomRecipe(keywords[mealTypesKey]).then((result) => {
+ return result
+ }),
+ currentEntry.shared = await apiClient.listUserPreferences().then((result) => {
+ return result.data[0].plan_share
+ }),
+ currentEntry.meal_type = await this.getMealType(meal_type[mealTypesKey].id).then((result) => {
+ return result
+ })
+ ])
+ currentEntry.title = currentEntry.recipe.name
+ this.createEntry(currentEntry)
+ },
+ doAutoPlan(autoPlan) {
+ let dayInMilliseconds = (86400000)
+ let numberOfDays = ((autoPlan.endDay - autoPlan.startDay) / dayInMilliseconds) + 1
- for (const mealTypesKey in autoPlan.meal_types) {
- for (let dateOffset = 0; dateOffset < numberOfDays; dateOffset++) {
- this.autoPlanThread(autoPlan.date, dateOffset, autoPlan.meal_types, autoPlan.keywords, autoPlan.servings, mealTypesKey)
- }
- }
+ for (const mealTypesKey in autoPlan.meal_types) {
+ for (let dateOffset = 0; dateOffset < numberOfDays; dateOffset++) {
+ this.autoPlanThread(autoPlan.startDay, dateOffset, autoPlan.meal_types, autoPlan.keywords, autoPlan.servings, mealTypesKey)
+ }
+ }
},
randomRecipe(keywords) {
- let url = "/api/recipe/?query="
- for (const keywordsKey in keywords) {
- let keyword = keywords[keywordsKey]
- url += `&keywords_and=${keyword.id}`
- }
- return axios.get(url).then((response) => {
- let result = response.data
- let count = result.count
- return result.results[Math.floor(Math.random() * count)]
- }).catch((err) => {
+ let url = "/api/recipe/?query="
+ for (const keywordsKey in keywords) {
+ let keyword = keywords[keywordsKey]
+ url += `&keywords_and=${keyword.id}`
+ }
+ return axios.get(url).then((response) => {
+ let result = response.data
+ let count = result.count
+ return result.results[Math.floor(Math.random() * count)]
+ }).catch((err) => {
- })
+ })
},
getMealType(id) {
- let url = `/api/meal-type/${id}`
- return axios.get(url).then((response) => {
- return response.data
- })
+ let url = `/api/meal-type/${id}`
+ return axios.get(url).then((response) => {
+ return response.data
+ })
}
},
directives: {