Skip to content

Commit

Permalink
first version of meal plan diaglo
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Mar 29, 2024
1 parent dcf7d44 commit cb98b67
Show file tree
Hide file tree
Showing 8 changed files with 1,916 additions and 42 deletions.
56 changes: 50 additions & 6 deletions vue3/src/components/dialogs/MealPlanDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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']">
Expand All @@ -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>
Expand All @@ -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";
Expand All @@ -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(),
Expand All @@ -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>
Expand Down
22 changes: 10 additions & 12 deletions vue3/src/components/display/HorizontalMealPlanWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
20 changes: 19 additions & 1 deletion vue3/src/openapi/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ index.ts
models/AccessToken.ts
models/AuthToken.ts
models/Automation.ts
models/AutomationTypeEnum.ts
models/BaseUnitEnum.ts
models/BookmarkletImport.ts
models/BookmarkletImportList.ts
models/ConnectorConfigConfig.ts
Expand All @@ -28,6 +30,16 @@ models/MealPlan.ts
models/MealType.ts
models/MethodEnum.ts
models/NutritionInformation.ts
models/OpenDataCategory.ts
models/OpenDataConversion.ts
models/OpenDataFood.ts
models/OpenDataFoodProperty.ts
models/OpenDataProperty.ts
models/OpenDataStore.ts
models/OpenDataStoreCategory.ts
models/OpenDataUnit.ts
models/OpenDataUnitTypeEnum.ts
models/OpenDataVersion.ts
models/PaginatedAutomationList.ts
models/PaginatedCookLogList.ts
models/PaginatedCustomFilterList.ts
Expand Down Expand Up @@ -57,6 +69,13 @@ models/PatchedInviteLink.ts
models/PatchedKeyword.ts
models/PatchedMealPlan.ts
models/PatchedMealType.ts
models/PatchedOpenDataCategory.ts
models/PatchedOpenDataConversion.ts
models/PatchedOpenDataFood.ts
models/PatchedOpenDataProperty.ts
models/PatchedOpenDataStore.ts
models/PatchedOpenDataUnit.ts
models/PatchedOpenDataVersion.ts
models/PatchedProperty.ts
models/PatchedPropertyType.ts
models/PatchedRecipe.ts
Expand Down Expand Up @@ -101,7 +120,6 @@ models/SupermarketCategoryRelation.ts
models/Sync.ts
models/SyncLog.ts
models/ThemeEnum.ts
models/TypeEnum.ts
models/Unit.ts
models/UnitConversion.ts
models/User.ts
Expand Down
Loading

0 comments on commit cb98b67

Please sign in to comment.