Started adding nutrition editing logic.

This commit is contained in:
matthias committed 2026-09-28 03:46:36 +02:00
1 parent 3ae697d852
commit d613f8c1d7
6 files changed
+306 -15

No files matched your search

+119 -5
View File
@@ -12,12 +12,23 @@
let loading: Ref<boolean> = ref<boolean>(false);
let dialog: Ref<boolean> = ref<boolean>(false);
async function updateNutrition() {
async function createNutrition() {
if (store.article != null) {
await store.createArticleNutrition(store.article.id);
}
}
async function updateNutrition() {
if (props.nutrition != null) {
await store.updateNutrition(props.nutrition);
}
}
async function deleteNutrition() {
if (props.nutrition != null) {
await store.deleteNutrition(props.nutrition)
}
closeDialog();
}
@@ -75,16 +86,119 @@
<v-divider/>
<v-card-text>
test
<div v-if="props.nutrition != null">
<v-row>
<v-col>
<v-text-field
v-model="props.nutrition.calorific_value_kcal"
:disabled="loading"
hint="Brennwert in kcal"
label="Brennwert"
suffix="kcal"
type="number"
></v-text-field>
</v-col>
<v-col>
<v-text-field
v-model="props.nutrition.calorific_value_kj"
:disabled="loading"
hint="Brennwert in kj"
label="Brennwert"
suffix="kj"
type="number"
></v-text-field>
</v-col>
</v-row>
<v-text-field
v-model="props.nutrition.fat"
:disabled="loading"
hint="Fett in g"
label="Fett"
suffix="g"
type="number"
></v-text-field>
<v-text-field
v-model="props.nutrition.saturated_fat"
:disabled="loading"
hint="Gesättigte Fettsäuren in g"
label="Gesättigte Fettsäuren"
suffix="g"
type="number"
></v-text-field>
<v-text-field
v-model="props.nutrition.carbohydrates"
:disabled="loading"
hint="Kohlenhydrate in g"
label="Kohlenhydrate"
suffix="g"
type="number"
></v-text-field>
<v-text-field
v-model="props.nutrition.sugar"
:disabled="loading"
hint="Zucker in g"
label="Zucker"
suffix="g"
type="number"
></v-text-field>
<v-text-field
v-model="props.nutrition.fibers"
:disabled="loading"
hint="Ballaststoffe in g"
label="Ballaststoffe"
suffix="g"
type="number"
></v-text-field>
<v-text-field
v-model="props.nutrition.protein"
:disabled="loading"
hint="Eiweiß in g"
label="Eiweiß"
suffix="g"
type="number"
></v-text-field>
<v-text-field
v-model="props.nutrition.salt"
:disabled="loading"
hint="Salz in g"
label="Salz"
suffix="g"
type="number"
></v-text-field>
</div>
<div v-else>
Keine Nährwerte hinterlegt
</div>
</v-card-text>
<v-divider/>
<v-card-actions>
<v-spacer/>
<v-btn
v-if="props.nutrition == null"
variant="text"
:disabled="loading"
@click="createNutrition()"
>
Hinzufügen
</v-btn>
<DeleteConfirm
v-else
title="Nährwert löschen?"
:disable="!loading"
:disable="loading"
@delete="deleteNutrition()"
/>
<v-divider vertical/>
@@ -92,7 +206,7 @@
<v-btn
variant="text"
:disabled="loading"
@click="closeDialog()"
@click="updateNutrition()"
>
Speichern
</v-btn>