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
@@ -1,47 +1,54 @@
<script setup lang="ts">
import type {Ref} from "vue";
import {useLabelEditorStore} from "~/store/labelEditorStore";
import { Variant } from "~/types/variant";
import type {Ref} from "vue";
import {useLabelEditorStore} from "~/store/labelEditorStore";
import { Variant } from "~/types/variant";
import type {Unit} from "~/types/unit";
let store = useLabelEditorStore();
let store = useLabelEditorStore();
let dialog: Ref<boolean> = ref<boolean>(false);
let loading: Ref<boolean> = ref<boolean>(false);
let dialog: Ref<boolean> = ref<boolean>(false);
let loading: Ref<boolean> = ref<boolean>(false);
let weight: Ref<string | null> = ref<string | null>(null);
let ean: Ref<string | null> = ref<string | null>(null);
let name: Ref<string | null> = ref<string | null>(null);
let description: Ref<string | null> = ref<string | null>(null);
let ingredients: Ref<string | null> = ref<string | null>(null);
let weight: Ref<string | null> = ref<string | null>(null);
let ean: Ref<string | null> = ref<string | null>(null);
let name: Ref<string | null> = ref<string | null>(null);
let unit: Ref<Unit | null> = ref<Unit | null>(null);
let description: Ref<string | null> = ref<string | null>(null);
let ingredients: Ref<string | null> = ref<string | null>(null);
async function create() {
if (store.article != null &&
weight.value != null && weight.value.trim().length > 0
) {
loading.value = true;
const variant: Variant = new Variant(0, weight.value, ean.value, name.value, description.value, ingredients.value);
await store.addVariant(variant);
closeDialog();
if (store.article != null) {
unit.value = store.article.default_unit;
}
}
function closeDialog() {
dialog.value = false;
clearVariables();
}
async function create() {
if (store.article != null &&
weight.value != null && weight.value.trim().length > 0 &&
unit.value != null && unit.value.trim().length > 0
) {
loading.value = true;
function clearVariables() {
weight.value = null;
ean.value = null;
name.value = null;
description.value = null;
ingredients.value = null;
const variant: Variant = new Variant(0, weight.value, ean.value, name.value, description.value, ingredients.value, unit.value);
loading.value = false;
}
await store.addVariant(variant);
closeDialog();
}
}
function closeDialog() {
dialog.value = false;
clearVariables();
}
function clearVariables() {
weight.value = null;
ean.value = null;
name.value = null;
description.value = null;
ingredients.value = null;
loading.value = false;
}
</script>
<template>
@@ -87,10 +94,21 @@ function clearVariables() {
autofocus
/>
<v-text-field
v-model.trim="weight"
label="Gewicht"
/>
<v-row>
<v-col>
<v-text-field
v-model.trim="weight"
label="Gewicht"
/>
</v-col>
<v-col>
<v-select
v-model="unit"
:items="store.units"
label="Einheit"
></v-select>
</v-col>
</v-row>
<v-textarea
v-model.trim="ean"