almost nothing and broken

This commit is contained in:
vabene1111
2024-07-18 20:03:06 +02:00
parent 45a6564e17
commit 6f44c8ba17
2 changed files with 25 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<template> <template>
<v-dialog activator="parent" v-model="dialog"> <v-dialog activator="parent" v-model="dialog" max-width="1200">
<template v-slot:default="{ isActive }"> <template v-slot:default="{ isActive }">
<v-card style="overflow: auto"> <v-card style="overflow: auto">
<v-card-title>Meal Plan Edit <v-card-title>Meal Plan Edit
@@ -21,6 +21,7 @@
<ModelSelect model="MealType" :allow-create="true" v-model="mutableMealPlan.mealType"></ModelSelect> <ModelSelect model="MealType" :allow-create="true" v-model="mutableMealPlan.mealType"></ModelSelect>
<v-number-input control-variant="split" :min="0" v-model="mutableMealPlan.servings"></v-number-input> <v-number-input control-variant="split" :min="0" v-model="mutableMealPlan.servings"></v-number-input>
<v-text-field label="Share" v-model="mutableMealPlan.shared"></v-text-field> <v-text-field label="Share" v-model="mutableMealPlan.shared"></v-text-field>
<ModelSelect model="User" :allow-create="false" v-model="mutableMealPlan.shared"></ModelSelect>
</v-col> </v-col>
<v-col cols="12" md="6"> <v-col cols="12" md="6">
<ModelSelect model="recipe" v-model="mutableMealPlan.recipe"></ModelSelect> <ModelSelect model="recipe" v-model="mutableMealPlan.recipe"></ModelSelect>

View File

@@ -1,4 +1,4 @@
import {ApiApi, Keyword as IKeyword, Food as IFood, RecipeOverview as IRecipeOverview, Recipe as IRecipe, Unit as IUnit, MealType as IMealType} from "@/openapi"; import {ApiApi, Keyword as IKeyword, Food as IFood, RecipeOverview as IRecipeOverview, Recipe as IRecipe, Unit as IUnit, MealType as IMealType, User as IUser} from "@/openapi";
export function getModelFromStr(model_name: String) { export function getModelFromStr(model_name: String) {
switch (model_name.toLowerCase()) { switch (model_name.toLowerCase()) {
@@ -17,6 +17,9 @@ export function getModelFromStr(model_name: String) {
case 'mealtype': { case 'mealtype': {
return new MealType return new MealType
} }
case 'user': {
return new User
}
default: { default: {
throw Error(`Invalid Model ${model_name}, did you forget to register it in Models.ts?`) throw Error(`Invalid Model ${model_name}, did you forget to register it in Models.ts?`)
} }
@@ -122,4 +125,23 @@ export class MealType extends GenericModel<IMealType> {
} }
}) })
} }
}
export class User extends GenericModel<IUser> {
create(name: string) {
return new Promise<undefined>( () => {
return undefined
})
}
list(query: string) {
const api = new ApiApi()
return api.apiUserList({}).then(r => {
if (r) {
return r
} else {
return []
}
})
}
} }