first version of meal plan diaglo

This commit is contained in:
vabene1111
2024-03-29 20:08:48 +01:00
parent dcf7d44d72
commit cb98b6723f
8 changed files with 1916 additions and 42 deletions

View File

@@ -6,8 +6,22 @@
<v-divider></v-divider> <v-divider></v-divider>
<v-card-text> <v-card-text>
<Vueform v-model="mutableMealPlan" sync> <Vueform v-model="mutableMealPlan" sync>
<HiddenElement meta input-type="number" name="id"></HiddenElement>
<TextElement name="title" :columns="{ sm: 12, md : 6}" label="Title"></TextElement> <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"> <DateElement name="fromDate" :columns="{ sm: 12, md : 6}" label="From Date">
<template #addon-after> <template #addon-after>
<v-btn-group style="border-radius: 0"> <v-btn-group style="border-radius: 0">
@@ -29,20 +43,29 @@
<GroupElement name="container_1_col_1" :columns="{ sm: 12, md : 6}"> <GroupElement name="container_1_col_1" :columns="{ sm: 12, md : 6}">
<SelectElement <SelectElement
name="mealType" name="mealType"
:default="mealPlan?.mealType"
label="Meal Type" label="Meal Type"
label-prop="name" label-prop="name"
value-prop="id" value-prop="id"
:object="true"
:strict="false" :strict="false"
:search="true" :search="true"
:items="mealTypeSearch" :items="mealTypeSearch"
:delay="300" :delay="300"
rules="required" rules="required"
> >
</SelectElement> </SelectElement>
<TextElement name="servings" label="Servings"></TextElement> <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>
<GroupElement name="container_1_col_2" :columns="{ sm: 12, md : 6}"> <GroupElement name="container_1_col_2" :columns="{ sm: 12, md : 6}">
<StaticElement name="static_1" :remove-class="['vf-contains-link']"> <StaticElement name="static_1" :remove-class="['vf-contains-link']">
@@ -58,7 +81,7 @@
<v-btn color="error"> <v-btn color="error">
Delete Delete
</v-btn> </v-btn>
<v-btn color="success" class="ml-auto"> <v-btn color="success" class="ml-auto" @click="saveMealPlan">
Save Save
</v-btn> </v-btn>
</v-card-actions> </v-card-actions>
@@ -69,7 +92,7 @@
<script setup lang="ts"> <script setup lang="ts">
import {onMounted, PropType, ref, watchEffect} from "vue"; import {onMounted, PropType, ref, watchEffect} from "vue";
import {ApiApi, MealPlan} from "@/openapi"; import {ApiApi, MealPlan, RecipeOverview} from "@/openapi";
import {DateTime} from "luxon"; import {DateTime} from "luxon";
import RecipeCard from "@/components/display/RecipeCard.vue"; 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() { function newMealPlan() {
return { return {
fromDate: DateTime.now().toJSDate(), fromDate: DateTime.now().toJSDate(),
@@ -103,6 +135,18 @@ async function mealTypeSearch(searchQuery: string) {
return await api.apiMealTypeList() 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> </script>
<style scoped> <style scoped>

View File

@@ -80,19 +80,17 @@ type MealPlanGridItem = {
const meal_plan_grid = computed(() => { const meal_plan_grid = computed(() => {
let grid = [] as MealPlanGridItem[] let grid = [] as MealPlanGridItem[]
if (useMealPlanStore().plan_list.length > 0) { for (const x of Array(4).keys()) {
console.log('found plans') let grid_day_date = DateTime.now().plus({days: x})
for (const x of Array(4).keys()) { console.log('going trough days ', x, grid_day_date)
let grid_day_date = DateTime.now().plus({days: x}) grid.push({
console.log('going trough days ', x, grid_day_date) date: grid_day_date,
grid.push({ create_default_date: grid_day_date.toISODate(), // improve meal plan edit modal to do formatting itself and accept dates
date: grid_day_date, date_label: grid_day_date.toLocaleString(DateTime.DATE_MED),
create_default_date: grid_day_date.toISODate(), // improve meal plan edit modal to do formatting itself and accept dates 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')))),
date_label: grid_day_date.toLocaleString(DateTime.DATE_MED), } as MealPlanGridItem)
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 return grid
}) })

View File

@@ -6,6 +6,8 @@ index.ts
models/AccessToken.ts models/AccessToken.ts
models/AuthToken.ts models/AuthToken.ts
models/Automation.ts models/Automation.ts
models/AutomationTypeEnum.ts
models/BaseUnitEnum.ts
models/BookmarkletImport.ts models/BookmarkletImport.ts
models/BookmarkletImportList.ts models/BookmarkletImportList.ts
models/ConnectorConfigConfig.ts models/ConnectorConfigConfig.ts
@@ -28,6 +30,16 @@ models/MealPlan.ts
models/MealType.ts models/MealType.ts
models/MethodEnum.ts models/MethodEnum.ts
models/NutritionInformation.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/PaginatedAutomationList.ts
models/PaginatedCookLogList.ts models/PaginatedCookLogList.ts
models/PaginatedCustomFilterList.ts models/PaginatedCustomFilterList.ts
@@ -57,6 +69,13 @@ models/PatchedInviteLink.ts
models/PatchedKeyword.ts models/PatchedKeyword.ts
models/PatchedMealPlan.ts models/PatchedMealPlan.ts
models/PatchedMealType.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/PatchedProperty.ts
models/PatchedPropertyType.ts models/PatchedPropertyType.ts
models/PatchedRecipe.ts models/PatchedRecipe.ts
@@ -101,7 +120,6 @@ models/SupermarketCategoryRelation.ts
models/Sync.ts models/Sync.ts
models/SyncLog.ts models/SyncLog.ts
models/ThemeEnum.ts models/ThemeEnum.ts
models/TypeEnum.ts
models/Unit.ts models/Unit.ts
models/UnitConversion.ts models/UnitConversion.ts
models/User.ts models/User.ts

File diff suppressed because it is too large Load Diff

View File

@@ -13,12 +13,12 @@
*/ */
import { mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { TypeEnum } from './TypeEnum'; import type { AutomationTypeEnum } from './AutomationTypeEnum';
import { import {
TypeEnumFromJSON, AutomationTypeEnumFromJSON,
TypeEnumFromJSONTyped, AutomationTypeEnumFromJSONTyped,
TypeEnumToJSON, AutomationTypeEnumToJSON,
} from './TypeEnum'; } from './AutomationTypeEnum';
/** /**
* *
@@ -34,10 +34,10 @@ export interface Automation {
readonly id: number; readonly id: number;
/** /**
* *
* @type {TypeEnum} * @type {AutomationTypeEnum}
* @memberof Automation * @memberof Automation
*/ */
type: TypeEnum; type: AutomationTypeEnum;
/** /**
* *
* @type {string} * @type {string}
@@ -109,7 +109,7 @@ export function AutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean)
return { return {
'id': json['id'], 'id': json['id'],
'type': TypeEnumFromJSON(json['type']), 'type': AutomationTypeEnumFromJSON(json['type']),
'name': json['name'] == null ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': json['description'] == null ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'param1': json['param_1'] == null ? undefined : json['param_1'], 'param1': json['param_1'] == null ? undefined : json['param_1'],
@@ -127,7 +127,7 @@ export function AutomationToJSON(value?: Automation | null): any {
} }
return { return {
'type': TypeEnumToJSON(value['type']), 'type': AutomationTypeEnumToJSON(value['type']),
'name': value['name'], 'name': value['name'],
'description': value['description'], 'description': value['description'],
'param_1': value['param1'], 'param_1': value['param1'],

View File

@@ -13,12 +13,12 @@
*/ */
import { mapValues } from '../runtime'; import { mapValues } from '../runtime';
import type { TypeEnum } from './TypeEnum'; import type { AutomationTypeEnum } from './AutomationTypeEnum';
import { import {
TypeEnumFromJSON, AutomationTypeEnumFromJSON,
TypeEnumFromJSONTyped, AutomationTypeEnumFromJSONTyped,
TypeEnumToJSON, AutomationTypeEnumToJSON,
} from './TypeEnum'; } from './AutomationTypeEnum';
/** /**
* *
@@ -34,10 +34,10 @@ export interface PatchedAutomation {
readonly id?: number; readonly id?: number;
/** /**
* *
* @type {TypeEnum} * @type {AutomationTypeEnum}
* @memberof PatchedAutomation * @memberof PatchedAutomation
*/ */
type?: TypeEnum; type?: AutomationTypeEnum;
/** /**
* *
* @type {string} * @type {string}
@@ -106,7 +106,7 @@ export function PatchedAutomationFromJSONTyped(json: any, ignoreDiscriminator: b
return { return {
'id': json['id'] == null ? undefined : json['id'], 'id': json['id'] == null ? undefined : json['id'],
'type': json['type'] == null ? undefined : TypeEnumFromJSON(json['type']), 'type': json['type'] == null ? undefined : AutomationTypeEnumFromJSON(json['type']),
'name': json['name'] == null ? undefined : json['name'], 'name': json['name'] == null ? undefined : json['name'],
'description': json['description'] == null ? undefined : json['description'], 'description': json['description'] == null ? undefined : json['description'],
'param1': json['param_1'] == null ? undefined : json['param_1'], 'param1': json['param_1'] == null ? undefined : json['param_1'],
@@ -124,7 +124,7 @@ export function PatchedAutomationToJSON(value?: PatchedAutomation | null): any {
} }
return { return {
'type': TypeEnumToJSON(value['type']), 'type': AutomationTypeEnumToJSON(value['type']),
'name': value['name'], 'name': value['name'],
'description': value['description'], 'description': value['description'],
'param_1': value['param1'], 'param_1': value['param1'],

View File

@@ -3,6 +3,8 @@
export * from './AccessToken'; export * from './AccessToken';
export * from './AuthToken'; export * from './AuthToken';
export * from './Automation'; export * from './Automation';
export * from './AutomationTypeEnum';
export * from './BaseUnitEnum';
export * from './BookmarkletImport'; export * from './BookmarkletImport';
export * from './BookmarkletImportList'; export * from './BookmarkletImportList';
export * from './ConnectorConfigConfig'; export * from './ConnectorConfigConfig';
@@ -25,6 +27,16 @@ export * from './MealPlan';
export * from './MealType'; export * from './MealType';
export * from './MethodEnum'; export * from './MethodEnum';
export * from './NutritionInformation'; export * from './NutritionInformation';
export * from './OpenDataCategory';
export * from './OpenDataConversion';
export * from './OpenDataFood';
export * from './OpenDataFoodProperty';
export * from './OpenDataProperty';
export * from './OpenDataStore';
export * from './OpenDataStoreCategory';
export * from './OpenDataUnit';
export * from './OpenDataUnitTypeEnum';
export * from './OpenDataVersion';
export * from './PaginatedAutomationList'; export * from './PaginatedAutomationList';
export * from './PaginatedCookLogList'; export * from './PaginatedCookLogList';
export * from './PaginatedCustomFilterList'; export * from './PaginatedCustomFilterList';
@@ -54,6 +66,13 @@ export * from './PatchedInviteLink';
export * from './PatchedKeyword'; export * from './PatchedKeyword';
export * from './PatchedMealPlan'; export * from './PatchedMealPlan';
export * from './PatchedMealType'; export * from './PatchedMealType';
export * from './PatchedOpenDataCategory';
export * from './PatchedOpenDataConversion';
export * from './PatchedOpenDataFood';
export * from './PatchedOpenDataProperty';
export * from './PatchedOpenDataStore';
export * from './PatchedOpenDataUnit';
export * from './PatchedOpenDataVersion';
export * from './PatchedProperty'; export * from './PatchedProperty';
export * from './PatchedPropertyType'; export * from './PatchedPropertyType';
export * from './PatchedRecipe'; export * from './PatchedRecipe';
@@ -98,7 +117,6 @@ export * from './SupermarketCategoryRelation';
export * from './Sync'; export * from './Sync';
export * from './SyncLog'; export * from './SyncLog';
export * from './ThemeEnum'; export * from './ThemeEnum';
export * from './TypeEnum';
export * from './Unit'; export * from './Unit';
export * from './UnitConversion'; export * from './UnitConversion';
export * from './User'; export * from './User';

View File

@@ -1,8 +1,7 @@
<template> <template>
<v-container> <v-container>
<v-btn @click="testApi">Test API</v-btn>
</v-container> </v-container>
</template> </template>
@@ -27,6 +26,16 @@ export default defineComponent({
mounted() { mounted() {
}, },
methods: {
testApi: function () {
const api = new ApiApi()
api.apiMealPlanList().then(r => {
if (r.length > 0) {
api.apiMealPlanUpdate({id: r[0].id, mealPlan: r[0]})
}
})
}
}
}) })
</script> </script>