mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-03 21:37:49 -05:00
first version of meal plan diaglo
This commit is contained in:
@@ -6,8 +6,22 @@
|
||||
<v-divider></v-divider>
|
||||
<v-card-text>
|
||||
<Vueform v-model="mutableMealPlan" sync>
|
||||
<HiddenElement meta input-type="number" name="id"></HiddenElement>
|
||||
<TextElement name="title" :columns="{ sm: 12, md : 6}" label="Title"></TextElement>
|
||||
<SelectElement name="recipe" :columns="{ sm: 12, md : 6}" label="Recipe"></SelectElement>
|
||||
<SelectElement
|
||||
name="recipe"
|
||||
:columns="{ sm: 12, md : 6}"
|
||||
label="Recipe"
|
||||
label-prop="name"
|
||||
value-prop="id"
|
||||
:object="true"
|
||||
:strict="false"
|
||||
:search="true"
|
||||
:items="recipeSearch"
|
||||
:delay="300"
|
||||
rules="required"
|
||||
|
||||
></SelectElement>
|
||||
<DateElement name="fromDate" :columns="{ sm: 12, md : 6}" label="From Date">
|
||||
<template #addon-after>
|
||||
<v-btn-group style="border-radius: 0">
|
||||
@@ -29,20 +43,29 @@
|
||||
<GroupElement name="container_1_col_1" :columns="{ sm: 12, md : 6}">
|
||||
<SelectElement
|
||||
name="mealType"
|
||||
:default="mealPlan?.mealType"
|
||||
label="Meal Type"
|
||||
label-prop="name"
|
||||
value-prop="id"
|
||||
:object="true"
|
||||
:strict="false"
|
||||
:search="true"
|
||||
:items="mealTypeSearch"
|
||||
:delay="300"
|
||||
rules="required"
|
||||
|
||||
>
|
||||
</SelectElement>
|
||||
<TextElement name="servings" label="Servings"></TextElement>
|
||||
<TextElement name="share" label="Share"></TextElement>
|
||||
<TagsElement
|
||||
name="share"
|
||||
label="Share"
|
||||
label-prop="displayName"
|
||||
value-prop="id"
|
||||
:object="true"
|
||||
:strict="false"
|
||||
:search="true"
|
||||
:items="shareUserSearch"
|
||||
:delay="300"
|
||||
></TagsElement>
|
||||
</GroupElement>
|
||||
<GroupElement name="container_1_col_2" :columns="{ sm: 12, md : 6}">
|
||||
<StaticElement name="static_1" :remove-class="['vf-contains-link']">
|
||||
@@ -58,7 +81,7 @@
|
||||
<v-btn color="error">
|
||||
Delete
|
||||
</v-btn>
|
||||
<v-btn color="success" class="ml-auto">
|
||||
<v-btn color="success" class="ml-auto" @click="saveMealPlan">
|
||||
Save
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -69,7 +92,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import {onMounted, PropType, ref, watchEffect} from "vue";
|
||||
import {ApiApi, MealPlan} from "@/openapi";
|
||||
import {ApiApi, MealPlan, RecipeOverview} from "@/openapi";
|
||||
import {DateTime} from "luxon";
|
||||
import RecipeCard from "@/components/display/RecipeCard.vue";
|
||||
|
||||
@@ -90,6 +113,15 @@ watchEffect(() => {
|
||||
}
|
||||
});
|
||||
|
||||
function saveMealPlan() {
|
||||
const api = new ApiApi()
|
||||
if (mutableMealPlan.value) {
|
||||
console.log('UPDATING ', mutableMealPlan.value)
|
||||
mutableMealPlan.value.recipe = mutableMealPlan.value.recipe as RecipeOverview
|
||||
api.apiMealPlanUpdate({id: mutableMealPlan.value.id, mealPlan: mutableMealPlan.value})
|
||||
}
|
||||
}
|
||||
|
||||
function newMealPlan() {
|
||||
return {
|
||||
fromDate: DateTime.now().toJSDate(),
|
||||
@@ -103,6 +135,18 @@ async function mealTypeSearch(searchQuery: string) {
|
||||
return await api.apiMealTypeList()
|
||||
}
|
||||
|
||||
async function shareUserSearch(searchQuery: string) {
|
||||
console.log('called su search')
|
||||
const api = new ApiApi()
|
||||
return await api.apiUserList()
|
||||
}
|
||||
|
||||
async function recipeSearch(searchQuery: string) {
|
||||
console.log('called recipe search')
|
||||
const api = new ApiApi()
|
||||
return (await api.apiRecipeList({query: searchQuery})).results
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -80,19 +80,17 @@ type MealPlanGridItem = {
|
||||
const meal_plan_grid = computed(() => {
|
||||
let grid = [] as MealPlanGridItem[]
|
||||
|
||||
if (useMealPlanStore().plan_list.length > 0) {
|
||||
console.log('found plans')
|
||||
for (const x of Array(4).keys()) {
|
||||
let grid_day_date = DateTime.now().plus({days: x})
|
||||
console.log('going trough days ', x, grid_day_date)
|
||||
grid.push({
|
||||
date: grid_day_date,
|
||||
create_default_date: grid_day_date.toISODate(), // improve meal plan edit modal to do formatting itself and accept dates
|
||||
date_label: grid_day_date.toLocaleString(DateTime.DATE_MED),
|
||||
plan_entries: useMealPlanStore().plan_list.filter((m: MealPlan) => ((DateTime.fromJSDate(m.fromDate).startOf('day') <= grid_day_date.startOf('day')) && (DateTime.fromJSDate((m.toDate != undefined) ? m.toDate : m.fromDate).startOf('day') >= grid_day_date.startOf('day')))),
|
||||
} as MealPlanGridItem)
|
||||
}
|
||||
for (const x of Array(4).keys()) {
|
||||
let grid_day_date = DateTime.now().plus({days: x})
|
||||
console.log('going trough days ', x, grid_day_date)
|
||||
grid.push({
|
||||
date: grid_day_date,
|
||||
create_default_date: grid_day_date.toISODate(), // improve meal plan edit modal to do formatting itself and accept dates
|
||||
date_label: grid_day_date.toLocaleString(DateTime.DATE_MED),
|
||||
plan_entries: useMealPlanStore().plan_list.filter((m: MealPlan) => ((DateTime.fromJSDate(m.fromDate).startOf('day') <= grid_day_date.startOf('day')) && (DateTime.fromJSDate((m.toDate != undefined) ? m.toDate : m.fromDate).startOf('day') >= grid_day_date.startOf('day')))),
|
||||
} as MealPlanGridItem)
|
||||
}
|
||||
|
||||
return grid
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user