Added unit to db and structs/types.

This commit is contained in:
2026-01-26 22:09:32 +01:00
parent 7879f69255
commit 8a27639aad
14 changed files with 243 additions and 60 deletions
+13 -2
View File
@@ -3,6 +3,7 @@
import type {Ref} from "vue";
import {Variant} from "~/types/variant";
import DeleteConfirm from "~/components/ui/deleteConfirm.vue";
import type {Unit} from "~/types/unit";
let store = useLabelEditorStore();
@@ -15,6 +16,7 @@
let weight: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.weight)));
let ean: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.ean)));
let name: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.name)));
let unit: Ref<Unit | null> = ref<Unit | null>(JSON.parse(JSON.stringify(props.variant.unit)));
let description: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.description)));
let ingredients: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.ingredients)));
@@ -35,13 +37,14 @@
weight.value = JSON.parse(JSON.stringify(props.variant.weight));
ean.value = JSON.parse(JSON.stringify(props.variant.ean));
name.value = JSON.parse(JSON.stringify(props.variant.name));
unit.value = JSON.parse(JSON.stringify(props.variant.unit));
description.value = JSON.parse(JSON.stringify(props.variant.description));
ingredients.value = JSON.parse(JSON.stringify(props.variant.ingredients));
}
async function updateVariant() {
if (weight.value != null) {
let updateVariant: Variant = new Variant(props.variant.id, weight.value, ean.value, name.value, description.value, ingredients.value);
if (weight.value != null && unit.value != null) {
let updateVariant: Variant = new Variant(props.variant.id, weight.value, ean.value, name.value, description.value, ingredients.value, unit.value);
await store.updateVariant(updateVariant);
@@ -137,6 +140,14 @@
:readonly="!edit"
/>
</v-row>
<v-row>
<v-select
v-model="unit"
:items="store.units"
label="Einheit"
:readonly="!edit"
></v-select>
</v-row>
<v-row>
<v-text-field
v-model.trim="ean"