mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-05 14:18:51 -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,8 +80,6 @@ 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)
|
||||
@@ -92,7 +90,7 @@ const meal_plan_grid = computed(() => {
|
||||
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
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,12 +13,12 @@
|
||||
*/
|
||||
|
||||
import { mapValues } from '../runtime';
|
||||
import type { TypeEnum } from './TypeEnum';
|
||||
import type { AutomationTypeEnum } from './AutomationTypeEnum';
|
||||
import {
|
||||
TypeEnumFromJSON,
|
||||
TypeEnumFromJSONTyped,
|
||||
TypeEnumToJSON,
|
||||
} from './TypeEnum';
|
||||
AutomationTypeEnumFromJSON,
|
||||
AutomationTypeEnumFromJSONTyped,
|
||||
AutomationTypeEnumToJSON,
|
||||
} from './AutomationTypeEnum';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,10 +34,10 @@ export interface Automation {
|
||||
readonly id: number;
|
||||
/**
|
||||
*
|
||||
* @type {TypeEnum}
|
||||
* @type {AutomationTypeEnum}
|
||||
* @memberof Automation
|
||||
*/
|
||||
type: TypeEnum;
|
||||
type: AutomationTypeEnum;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
@@ -109,7 +109,7 @@ export function AutomationFromJSONTyped(json: any, ignoreDiscriminator: boolean)
|
||||
return {
|
||||
|
||||
'id': json['id'],
|
||||
'type': TypeEnumFromJSON(json['type']),
|
||||
'type': AutomationTypeEnumFromJSON(json['type']),
|
||||
'name': json['name'] == null ? undefined : json['name'],
|
||||
'description': json['description'] == null ? undefined : json['description'],
|
||||
'param1': json['param_1'] == null ? undefined : json['param_1'],
|
||||
@@ -127,7 +127,7 @@ export function AutomationToJSON(value?: Automation | null): any {
|
||||
}
|
||||
return {
|
||||
|
||||
'type': TypeEnumToJSON(value['type']),
|
||||
'type': AutomationTypeEnumToJSON(value['type']),
|
||||
'name': value['name'],
|
||||
'description': value['description'],
|
||||
'param_1': value['param1'],
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
*/
|
||||
|
||||
import { mapValues } from '../runtime';
|
||||
import type { TypeEnum } from './TypeEnum';
|
||||
import type { AutomationTypeEnum } from './AutomationTypeEnum';
|
||||
import {
|
||||
TypeEnumFromJSON,
|
||||
TypeEnumFromJSONTyped,
|
||||
TypeEnumToJSON,
|
||||
} from './TypeEnum';
|
||||
AutomationTypeEnumFromJSON,
|
||||
AutomationTypeEnumFromJSONTyped,
|
||||
AutomationTypeEnumToJSON,
|
||||
} from './AutomationTypeEnum';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,10 +34,10 @@ export interface PatchedAutomation {
|
||||
readonly id?: number;
|
||||
/**
|
||||
*
|
||||
* @type {TypeEnum}
|
||||
* @type {AutomationTypeEnum}
|
||||
* @memberof PatchedAutomation
|
||||
*/
|
||||
type?: TypeEnum;
|
||||
type?: AutomationTypeEnum;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
@@ -106,7 +106,7 @@ export function PatchedAutomationFromJSONTyped(json: any, ignoreDiscriminator: b
|
||||
return {
|
||||
|
||||
'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'],
|
||||
'description': json['description'] == null ? undefined : json['description'],
|
||||
'param1': json['param_1'] == null ? undefined : json['param_1'],
|
||||
@@ -124,7 +124,7 @@ export function PatchedAutomationToJSON(value?: PatchedAutomation | null): any {
|
||||
}
|
||||
return {
|
||||
|
||||
'type': TypeEnumToJSON(value['type']),
|
||||
'type': AutomationTypeEnumToJSON(value['type']),
|
||||
'name': value['name'],
|
||||
'description': value['description'],
|
||||
'param_1': value['param1'],
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
export * from './AccessToken';
|
||||
export * from './AuthToken';
|
||||
export * from './Automation';
|
||||
export * from './AutomationTypeEnum';
|
||||
export * from './BaseUnitEnum';
|
||||
export * from './BookmarkletImport';
|
||||
export * from './BookmarkletImportList';
|
||||
export * from './ConnectorConfigConfig';
|
||||
@@ -25,6 +27,16 @@ export * from './MealPlan';
|
||||
export * from './MealType';
|
||||
export * from './MethodEnum';
|
||||
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 './PaginatedCookLogList';
|
||||
export * from './PaginatedCustomFilterList';
|
||||
@@ -54,6 +66,13 @@ export * from './PatchedInviteLink';
|
||||
export * from './PatchedKeyword';
|
||||
export * from './PatchedMealPlan';
|
||||
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 './PatchedPropertyType';
|
||||
export * from './PatchedRecipe';
|
||||
@@ -98,7 +117,6 @@ export * from './SupermarketCategoryRelation';
|
||||
export * from './Sync';
|
||||
export * from './SyncLog';
|
||||
export * from './ThemeEnum';
|
||||
export * from './TypeEnum';
|
||||
export * from './Unit';
|
||||
export * from './UnitConversion';
|
||||
export * from './User';
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<template>
|
||||
<v-container>
|
||||
|
||||
<v-btn @click="testApi">Test API</v-btn>
|
||||
</v-container>
|
||||
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -27,6 +26,16 @@ export default defineComponent({
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user