Added topm id and row number and ui changes.
This commit is contained in:
@@ -21,6 +21,7 @@ pub struct Article {
|
||||
pub bio_origin: Option<String>,
|
||||
pub allergens_text: Option<String>,
|
||||
pub bio_info: Option<String>,
|
||||
pub topm_id: Option<String>,
|
||||
}
|
||||
|
||||
fn from_postgres_row_small(row: PgRow) -> Article {
|
||||
@@ -37,6 +38,7 @@ fn from_postgres_row_small(row: PgRow) -> Article {
|
||||
bio_origin: row.get(8),
|
||||
allergens_text: row.get(9),
|
||||
bio_info: row.get(10),
|
||||
topm_id: row.get(11),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +69,7 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article {
|
||||
bio_origin: row.get(8),
|
||||
allergens_text: row.get(9),
|
||||
bio_info: row.get(10),
|
||||
topm_id: row.get(11),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,9 +140,10 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
|
||||
args.add(&article.bio_origin);
|
||||
args.add(&article.allergens_text);
|
||||
args.add(&article.bio_info);
|
||||
args.add(&article.topm_id);
|
||||
|
||||
let statement = format!(
|
||||
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *",
|
||||
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info, topm_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *",
|
||||
"article",
|
||||
);
|
||||
|
||||
@@ -176,9 +180,10 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
|
||||
args.add(&article.bio_origin);
|
||||
args.add(&article.allergens_text);
|
||||
args.add(&article.bio_info);
|
||||
args.add(&article.topm_id);
|
||||
|
||||
let statement = format!(
|
||||
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11 WHERE id = $1 RETURNING *",
|
||||
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11, topm_id = $12 WHERE id = $1 RETURNING *",
|
||||
"article",
|
||||
);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ pub struct Variant {
|
||||
pub unit: Unit,
|
||||
pub label: Option<Label>,
|
||||
pub variant_description: Option<String>,
|
||||
pub topm_row: Option<String>,
|
||||
}
|
||||
|
||||
async fn from_postgres_row(row: PgRow, pool: &PgPool) -> Variant {
|
||||
@@ -39,6 +40,7 @@ async fn from_postgres_row(row: PgRow, pool: &PgPool) -> Variant {
|
||||
unit: row.get(7),
|
||||
label: label,
|
||||
variant_description: row.get(9),
|
||||
topm_row: row.get(10),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +96,10 @@ pub async fn insert_variant(article_id: i64, variant: &Variant, pool: PgPool) ->
|
||||
args.add(&variant.unit);
|
||||
args.add(label_id);
|
||||
args.add(&variant.variant_description);
|
||||
args.add(&variant.topm_row);
|
||||
|
||||
let statement = format!(
|
||||
"INSERT INTO {} (article_id, weight, ean, name, description, ingredients, unit_id, label_id, variant_description) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *",
|
||||
"INSERT INTO {} (article_id, weight, ean, name, description, ingredients, unit_id, label_id, variant_description, topm_row) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *",
|
||||
"variant",
|
||||
);
|
||||
|
||||
@@ -139,11 +142,12 @@ pub async fn update_variant(variant_id: i64, variant: &Variant, pool: PgPool) ->
|
||||
args.add(&variant.unit);
|
||||
args.add(label_id);
|
||||
args.add(&variant.variant_description);
|
||||
args.add(&variant.topm_row);
|
||||
|
||||
info!("Variant: {:#?}", variant);
|
||||
|
||||
let statement = format!(
|
||||
"UPDATE {} SET weight = $2, ean = $3, name = $4, description = $5, ingredients = $6, unit_id = $7, label_id = $8, variant_description = $9 WHERE id = $1 RETURNING *",
|
||||
"UPDATE {} SET weight = $2, ean = $3, name = $4, description = $5, ingredients = $6, unit_id = $7, label_id = $8, variant_description = $9, topm_row = $10 WHERE id = $1 RETURNING *",
|
||||
"variant",
|
||||
);
|
||||
|
||||
|
||||
@@ -116,6 +116,14 @@
|
||||
<v-card-text>
|
||||
<v-row no-gutters>
|
||||
<v-col cols="2" style="padding: 5px;">
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="store.articleEdit.topm_id"
|
||||
:readonly="!edit"
|
||||
label="TopM ID"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-checkbox
|
||||
v-model="store.articleEdit.bio"
|
||||
@@ -150,6 +158,7 @@
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
:readonly="!edit"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
|
||||
@@ -161,6 +170,7 @@
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
:readonly="!edit"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
</v-col>
|
||||
@@ -174,6 +184,7 @@
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
:readonly="!edit"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
@@ -205,6 +216,7 @@
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
:readonly="!edit"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
let bio_origin: Ref<string | null> = ref<string | null>(null);
|
||||
let allergens_text: Ref<string | null> = ref<string | null>(null);
|
||||
let bio_info: Ref<string | null> = ref<string | null>(null);
|
||||
let topm_id: Ref<string | null> = ref<string | null>(null);
|
||||
|
||||
async function create() {
|
||||
if (name.value != null && name.value.trim().length > 0 &&
|
||||
@@ -30,7 +31,7 @@
|
||||
|
||||
const article: Article = new Article(0, name.value, bio.value, origin.value, description.value,
|
||||
ingredients.value, default_unit.value, [],
|
||||
mhd.value, bio_origin.value, allergens_text.value, bio_info.value);
|
||||
mhd.value, bio_origin.value, allergens_text.value, bio_info.value, topm_id.value);
|
||||
|
||||
await store.createArticle(article);
|
||||
|
||||
@@ -53,6 +54,7 @@
|
||||
bio_origin.value = null;
|
||||
allergens_text.value = null;
|
||||
bio_info.value = null;
|
||||
topm_id.value = null;
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -63,7 +65,7 @@
|
||||
v-model="dialog"
|
||||
:scrollable="true"
|
||||
width="800"
|
||||
max-height="750"
|
||||
max-height="850"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn
|
||||
@@ -122,16 +124,25 @@
|
||||
label="Standard Einheit"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model.trim="topm_id"
|
||||
label="TopM ID"
|
||||
:clearable="true"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-textarea
|
||||
v-model.trim="description"
|
||||
label="Beschreibung"
|
||||
:clearable="true"
|
||||
/>
|
||||
|
||||
<v-textarea
|
||||
v-model.trim="ingredients"
|
||||
label="Zutaten"
|
||||
:clearable="true"
|
||||
/>
|
||||
|
||||
<v-row>
|
||||
@@ -140,6 +151,7 @@
|
||||
v-model.trim="mhd"
|
||||
label="MHD Text"
|
||||
:hint="store.settings.mhd"
|
||||
:clearable="true"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
@@ -147,6 +159,7 @@
|
||||
v-model.trim="allergens_text"
|
||||
label="Allergen Hinweis"
|
||||
:hint="store.settings.allergens_text"
|
||||
:clearable="true"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -157,6 +170,7 @@
|
||||
v-model.trim="bio_origin"
|
||||
label="BIO Prüfstelle"
|
||||
:hint="store.settings.bio"
|
||||
:clearable="true"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
@@ -164,6 +178,7 @@
|
||||
v-model.trim="bio_info"
|
||||
label="BIO Info Text"
|
||||
:hint="store.settings.bio_info"
|
||||
:clearable="true"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
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);
|
||||
let topm_row: Ref<string | null> = ref<string | null>(null);
|
||||
|
||||
if (store.article != null) {
|
||||
unit.value = store.article.default_unit;
|
||||
@@ -30,7 +31,9 @@
|
||||
) {
|
||||
loading.value = true;
|
||||
|
||||
const variant: Variant = new Variant(0, weight.value, ean.value, name.value, description.value, ingredients.value, unit.value, label.value, variant_description.value);
|
||||
const variant: Variant = new Variant(0, weight.value, ean.value, name.value,
|
||||
description.value, ingredients.value, unit.value, label.value,
|
||||
variant_description.value, topm_row.value);
|
||||
|
||||
await store.addVariant(variant);
|
||||
|
||||
@@ -44,11 +47,17 @@
|
||||
}
|
||||
|
||||
function clearVariables() {
|
||||
if (store.article != null) {
|
||||
weight.value = null;
|
||||
ean.value = null;
|
||||
name.value = null;
|
||||
unit.value = store.article.default_unit;
|
||||
description.value = null;
|
||||
ingredients.value = null;
|
||||
label.value = null;
|
||||
variant_description.value = null;
|
||||
topm_row.value = null;
|
||||
}
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -59,7 +68,7 @@
|
||||
v-model="dialog"
|
||||
:scrollable="true"
|
||||
width="800"
|
||||
max-height="750"
|
||||
max-height="850"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn
|
||||
@@ -91,15 +100,29 @@
|
||||
<v-divider/>
|
||||
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
<v-col cols="8">
|
||||
<v-text-field
|
||||
v-model.trim="variant_description"
|
||||
label="Varianten Bezeichnung"
|
||||
autofocus
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model.trim="topm_row"
|
||||
label="TopM Zeile"
|
||||
:clearable="true"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-text-field
|
||||
v-model.trim="name"
|
||||
label="Produkt Bezeichnung"
|
||||
:clearable="true"
|
||||
:placeholder="(store.article != null)? ((store.article.name != null)? store.article.name : undefined) : undefined"
|
||||
persistent-placeholder
|
||||
/>
|
||||
|
||||
<v-row>
|
||||
@@ -131,16 +154,23 @@
|
||||
<v-text-field
|
||||
v-model.trim="ean"
|
||||
label="EAN-Code"
|
||||
:clearable="true"
|
||||
/>
|
||||
|
||||
<v-textarea
|
||||
v-model.trim="description"
|
||||
label="Beschreibung"
|
||||
:clearable="true"
|
||||
:placeholder="(store.article != null)? ((store.article.description != null)? store.article.description : undefined) : undefined"
|
||||
persistent-placeholder
|
||||
/>
|
||||
|
||||
<v-textarea
|
||||
v-model.trim="ingredients"
|
||||
label="Zutaten"
|
||||
:clearable="true"
|
||||
:placeholder="(store.article != null)? ((store.article.ingredients != null)? store.article.ingredients : undefined) : undefined"
|
||||
persistent-placeholder
|
||||
/>
|
||||
</v-card-text>
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
let ingredients: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.ingredients)));
|
||||
let label: Ref<Label | null> = ref<Label | null>(JSON.parse(JSON.stringify(props.variant.label)));
|
||||
let variant_description: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.variant_description)));
|
||||
let topm_row: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.variant.topm_row)));
|
||||
|
||||
function toggleEdit() {
|
||||
if (edit.value) {
|
||||
@@ -43,13 +44,14 @@
|
||||
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));
|
||||
topm_row.value = JSON.parse(JSON.stringify(props.variant.topm_row));
|
||||
}
|
||||
|
||||
async function updateVariant() {
|
||||
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, label.value, variant_description.value);
|
||||
unit.value, label.value, variant_description.value, topm_row.value);
|
||||
|
||||
await store.updateVariant(updateVariant);
|
||||
|
||||
@@ -135,11 +137,17 @@
|
||||
<v-divider/>
|
||||
|
||||
<v-card-text>
|
||||
<v-row
|
||||
align="start"
|
||||
>
|
||||
<v-col cols="2">
|
||||
<v-row>
|
||||
<v-row no-gutters>
|
||||
<v-col cols="2" style="padding: 5px;">
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="topm_row"
|
||||
label="TopM Zeile"
|
||||
:readonly="!edit"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-select
|
||||
v-model="label"
|
||||
:items="store.labels"
|
||||
@@ -149,17 +157,16 @@
|
||||
item-title="name"
|
||||
:clearable="edit"
|
||||
no-data-text="Keine Etiketten Typen angelegt"
|
||||
|
||||
/>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="weight"
|
||||
label="Gewicht"
|
||||
:readonly="!edit"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-row no-gutters>
|
||||
<v-select
|
||||
v-model="unit"
|
||||
:items="store.units"
|
||||
@@ -169,13 +176,17 @@
|
||||
</v-row>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="5">
|
||||
<v-col cols="5" style="padding: 5px;">
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="name"
|
||||
:readonly="!edit"
|
||||
label="Produkt Bezeichnung"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
|
||||
<v-row no-gutters>
|
||||
<v-textarea
|
||||
v-model.trim="description"
|
||||
:tile=true
|
||||
@@ -185,22 +196,28 @@
|
||||
rows="6"
|
||||
no-resize
|
||||
:readonly="!edit"
|
||||
:placeholder="(store.article != null)? ((store.article.ingredients != null)? store.article.ingredients : undefined) : undefined"
|
||||
:placeholder="(store.article != null)? ((store.article.ingredients != null)? store.article.description : undefined) : undefined"
|
||||
persistent-placeholder
|
||||
:clearable="edit"
|
||||
>
|
||||
<template v-slot:counter="{ counter }">
|
||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||
</template>
|
||||
</v-textarea>
|
||||
</v-row>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="5">
|
||||
<v-col cols="5" style="padding: 5px;">
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="ean"
|
||||
label="EAN"
|
||||
:readonly="!edit"
|
||||
:clearable="edit"
|
||||
/>
|
||||
</v-row>
|
||||
|
||||
<v-row no-gutters>
|
||||
<v-textarea
|
||||
v-model.trim="ingredients"
|
||||
:tile=true
|
||||
@@ -212,11 +229,13 @@
|
||||
:readonly="!edit"
|
||||
:placeholder="(store.article != null)? ((store.article.ingredients != null)? store.article.ingredients : undefined) : undefined"
|
||||
persistent-placeholder
|
||||
:clearable="edit"
|
||||
>
|
||||
<template v-slot:counter="{ counter }">
|
||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||
</template>
|
||||
</v-textarea>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
@@ -292,6 +292,7 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
||||
this.article.bio_origin = updatedArticle.bio_origin;
|
||||
this.article.bio_info = updatedArticle.bio_info;
|
||||
this.article.allergens_text = updatedArticle.allergens_text;
|
||||
this.article.topm_id = updatedArticle.topm_id;
|
||||
|
||||
this.addNotification(false, 'Artikel "' + article.name + '" aktualisiert');
|
||||
} catch {
|
||||
|
||||
@@ -15,11 +15,12 @@ export class Article {
|
||||
bio_origin: string | null;
|
||||
allergens_text: string | null;
|
||||
bio_info: string | null;
|
||||
|
||||
topm_id: string | null;
|
||||
|
||||
constructor(id: number, name: string, bio: boolean, origin: Origin, description: string | null,
|
||||
ingredients: string | null, default_unit: Unit, variants: Array<Variant> | null,
|
||||
mhd: string | null, bio_origin: string | null, allergens_text: string | null, bio_info: string | null) {
|
||||
mhd: string | null, bio_origin: string | null, allergens_text: string | null,
|
||||
bio_info: string | null, topm_id: string | null) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.bio = bio;
|
||||
@@ -38,5 +39,6 @@ export class Article {
|
||||
this.bio_origin = bio_origin;
|
||||
this.allergens_text = allergens_text;
|
||||
this.bio_info = bio_info;
|
||||
this.topm_id = topm_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ export class Variant {
|
||||
unit: Unit;
|
||||
label: Label | null;
|
||||
variant_description: string | null;
|
||||
topm_row: string | null;
|
||||
|
||||
constructor(id: number, weight: string, ean: string|null, name: string|null,
|
||||
description:string|null, ingredients: string|null, unit: Unit,
|
||||
label: Label | null, variant_description: string | null) {
|
||||
label: Label | null, variant_description: string | null, topm_row: string | null) {
|
||||
this.id = id;
|
||||
this.weight = weight;
|
||||
this.ean = ean;
|
||||
@@ -24,5 +25,6 @@ export class Variant {
|
||||
this.unit = unit;
|
||||
this.label = label;
|
||||
this.variant_description = variant_description;
|
||||
this.topm_row = topm_row;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Add migration script here
|
||||
|
||||
ALTER TABLE public.article
|
||||
ADD topm_id text;
|
||||
|
||||
ALTER TABLE public.variant
|
||||
ADD topm_row text;
|
||||
@@ -118,6 +118,7 @@ async fn get_article(
|
||||
bio_origin: None,
|
||||
allergens_text: None,
|
||||
bio_info: None,
|
||||
topm_id: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||
@@ -150,6 +151,7 @@ async fn create_article(
|
||||
bio_origin: None,
|
||||
allergens_text: None,
|
||||
bio_info: None,
|
||||
topm_id: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||
@@ -184,6 +186,7 @@ async fn update_article_route(
|
||||
bio_origin: None,
|
||||
allergens_text: None,
|
||||
bio_info: None,
|
||||
topm_id: None
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||
@@ -234,6 +237,7 @@ async fn add_variant(
|
||||
unit: Unit::G,
|
||||
label: None,
|
||||
variant_description: None,
|
||||
topm_row: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(variant))
|
||||
@@ -265,6 +269,7 @@ async fn update_variant_route(
|
||||
unit: Unit::G,
|
||||
label: None,
|
||||
variant_description: None,
|
||||
topm_row: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(variant))
|
||||
|
||||
Reference in New Issue
Block a user