Updated ui for variant and label and fixed error with loading labe for variant.

This commit is contained in:
2026-01-31 18:47:30 +01:00
parent cb39f7ad32
commit 2ab51420dc
5 changed files with 61 additions and 13 deletions
+9 -1
View File
@@ -19,7 +19,15 @@ pub struct Variant {
} }
async fn from_postgres_row(row: PgRow, pool: &PgPool) -> Variant { async fn from_postgres_row(row: PgRow, pool: &PgPool) -> Variant {
let label = load_label(row.get(0), pool).await; let label_id_option: Option<i64> = row.get(8);
let label: Option<Label> = match label_id_option {
Some(label_id) => {
load_label(label_id, pool).await
}
None => {
None
}
};
Variant { Variant {
id: row.get(0), id: row.get(0),
@@ -50,6 +50,7 @@
<v-text-field <v-text-field
v-model.trim="store.articleEdit.name" v-model.trim="store.articleEdit.name"
:readonly="!edit" :readonly="!edit"
label="Produkt Bezeichnung"
/> />
<v-spacer /> <v-spacer />
@@ -3,6 +3,7 @@
import {useLabelEditorStore} from "~/store/labelEditorStore"; import {useLabelEditorStore} from "~/store/labelEditorStore";
import { Variant } from "~/types/variant"; import { Variant } from "~/types/variant";
import type {Unit} from "~/types/unit"; import type {Unit} from "~/types/unit";
import type {Label} from "~/types/label";
let store = useLabelEditorStore(); let store = useLabelEditorStore();
@@ -15,6 +16,8 @@
let unit: Ref<Unit | null> = ref<Unit | null>(null); let unit: Ref<Unit | null> = ref<Unit | null>(null);
let description: 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 ingredients: Ref<string | null> = ref<string | null>(null);
let label: Ref<Label | null> = ref<Label | null>(null);
let variant_description: Ref<string | null> = ref<string | null>(null);
if (store.article != null) { if (store.article != null) {
unit.value = store.article.default_unit; unit.value = store.article.default_unit;
@@ -27,7 +30,7 @@
) { ) {
loading.value = true; loading.value = true;
const variant: Variant = new Variant(0, weight.value, ean.value, name.value, description.value, ingredients.value, unit.value); const variant: Variant = new Variant(0, weight.value, ean.value, name.value, description.value, ingredients.value, unit.value, label.value, variant_description.value);
await store.addVariant(variant); await store.addVariant(variant);
@@ -89,12 +92,27 @@
<v-card-text> <v-card-text>
<v-text-field <v-text-field
v-model.trim="name" v-model.trim="variant_description"
label="Bezeichnung" label="Varianten Bezeichnung"
autofocus autofocus
/> />
<v-text-field
v-model.trim="name"
label="Produkt Bezeichnung"
/>
<v-row> <v-row>
<v-col>
<v-select
v-model="label"
:items="store.labels"
label="Etiketten Typ"
:return-object="true"
item-title="name"
no-data-text="Keine Etiketten Typen angelegt"
/>
</v-col>
<v-col> <v-col>
<v-text-field <v-text-field
v-model.trim="weight" v-model.trim="weight"
@@ -110,7 +128,7 @@
</v-col> </v-col>
</v-row> </v-row>
<v-textarea <v-text-field
v-model.trim="ean" v-model.trim="ean"
label="EAN-Code" label="EAN-Code"
/> />
+27 -8
View File
@@ -68,8 +68,9 @@
<v-card-title> <v-card-title>
<v-row style="padding-top: 10px"> <v-row style="padding-top: 10px">
<v-text-field <v-text-field
v-model.trim="name" v-model.trim="variant_description"
:readonly="!edit" :readonly="!edit"
label="Varianten Bezeichnung"
/> />
<v-spacer /> <v-spacer />
@@ -138,6 +139,19 @@
align="start" align="start"
> >
<v-col cols="2"> <v-col cols="2">
<v-row>
<v-select
v-model="label"
:items="store.labels"
label="Etiketten Typ"
:readonly="!edit"
:return-object="true"
item-title="name"
:clearable="edit"
no-data-text="Keine Etiketten Typen angelegt"
/>
</v-row>
<v-row> <v-row>
<v-text-field <v-text-field
v-model.trim="weight" v-model.trim="weight"
@@ -151,18 +165,17 @@
:items="store.units" :items="store.units"
label="Einheit" label="Einheit"
:readonly="!edit" :readonly="!edit"
></v-select>
</v-row>
<v-row>
<v-text-field
v-model.trim="ean"
label="EAN"
:readonly="!edit"
/> />
</v-row> </v-row>
</v-col> </v-col>
<v-col cols="5"> <v-col cols="5">
<v-text-field
v-model.trim="name"
:readonly="!edit"
label="Produkt Bezeichnung"
/>
<v-textarea <v-textarea
v-model.trim="description" v-model.trim="description"
:tile=true :tile=true
@@ -182,6 +195,12 @@
</v-col> </v-col>
<v-col cols="5"> <v-col cols="5">
<v-text-field
v-model.trim="ean"
label="EAN"
:readonly="!edit"
/>
<v-textarea <v-textarea
v-model.trim="ingredients" v-model.trim="ingredients"
:tile=true :tile=true
+2
View File
@@ -187,6 +187,8 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
// Article // Article
async loadArticle(articleID: number) { async loadArticle(articleID: number) {
await this.loadLabels();
try { try {
const article: Article = await $fetch<Article>(this.config.public.url + '/article/' + articleID, { const article: Article = await $fetch<Article>(this.config.public.url + '/article/' + articleID, {
method: 'GET', method: 'GET',