Added additional name filed to article.

This commit is contained in:
2026-02-25 15:49:42 +01:00
parent ba5ebc3524
commit 75a178cbf4
7 changed files with 46 additions and 5 deletions
+7 -2
View File
@@ -22,6 +22,7 @@ pub struct Article {
pub allergens_text: Option<String>,
pub bio_info: Option<String>,
pub topm_id: Option<String>,
pub additional_name: Option<String>,
}
fn from_postgres_row_small(row: PgRow) -> Article {
@@ -39,6 +40,7 @@ fn from_postgres_row_small(row: PgRow) -> Article {
allergens_text: row.get(9),
bio_info: row.get(10),
topm_id: row.get(11),
additional_name: row.get(12),
}
}
@@ -70,6 +72,7 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article {
allergens_text: row.get(9),
bio_info: row.get(10),
topm_id: row.get(11),
additional_name: row.get(12),
}
}
@@ -141,9 +144,10 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
args.add(&article.allergens_text);
args.add(&article.bio_info);
args.add(&article.topm_id);
args.add(&article.additional_name);
let statement = format!(
"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 *",
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info, topm_id, additional_name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING *",
"article",
);
@@ -181,9 +185,10 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
args.add(&article.allergens_text);
args.add(&article.bio_info);
args.add(&article.topm_id);
args.add(&article.additional_name);
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, topm_id = $12 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, additional_name = $13 WHERE id = $1 RETURNING *",
"article",
);
@@ -176,6 +176,18 @@
</v-col>
<v-col cols="5" style="padding: 5px;">
<v-row no-gutters>
<v-text-field
v-model.trim="store.articleEdit.additional_name"
label="Siegel Text"
:placeholder="store.articleEdit.name"
:hint="store.articleEdit.name"
persistent-placeholder
:persistent-hint="store.articleEdit.additional_name != null"
:readonly="!edit"
:clearable="edit"
/>
</v-row>
<v-row no-gutters>
<v-text-field
v-model.trim="store.articleEdit.bio_info"
@@ -21,6 +21,7 @@
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);
let additional_name: Ref<string | null> = ref<string | null>(null);
async function create() {
if (name.value != null && name.value.trim().length > 0 &&
@@ -36,7 +37,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, topm_id.value);
mhd.value, bio_origin.value, allergens_text.value, bio_info.value, topm_id.value, additional_name.value);
await store.createArticle(article);
@@ -60,6 +61,7 @@
allergens_text.value = null;
bio_info.value = null;
topm_id.value = null;
additional_name.value = null;
loading.value = false;
}
@@ -108,6 +110,15 @@
autofocus
/>
<v-text-field
v-model.trim="additional_name"
label="Siegel Text"
:placeholder="name"
:hint="name"
persistent-placeholder
:persistent-hint="additional_name != null"
/>
<v-row>
<v-col cols="2">
<v-checkbox
@@ -183,6 +183,10 @@
:readonly="!edit"
label="Produkt Bezeichnung"
:clearable="edit"
:placeholder="store.articleEdit.name"
:hint="store.articleEdit.name"
persistent-placeholder
:persistent-hint="store.articleEdit.additional_name != null"
/>
</v-row>
+3 -1
View File
@@ -16,11 +16,12 @@ export class Article {
allergens_text: string | null;
bio_info: string | null;
topm_id: string | null;
additional_name: 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, topm_id: string | null) {
bio_info: string | null, topm_id: string | null, additional_name: string | null) {
this.id = id;
this.name = name;
this.bio = bio;
@@ -40,5 +41,6 @@ export class Article {
this.allergens_text = allergens_text;
this.bio_info = bio_info;
this.topm_id = topm_id;
this.additional_name = additional_name;
}
}
@@ -0,0 +1,4 @@
-- Add migration script here
ALTER TABLE public.article
ADD additional_name text;
+4 -1
View File
@@ -119,6 +119,7 @@ async fn get_article(
allergens_text: None,
bio_info: None,
topm_id: None,
additional_name: None,
};
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
@@ -152,6 +153,7 @@ async fn create_article(
allergens_text: None,
bio_info: None,
topm_id: None,
additional_name: None,
};
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
@@ -186,7 +188,8 @@ async fn update_article_route(
bio_origin: None,
allergens_text: None,
bio_info: None,
topm_id: None
topm_id: None,
additional_name: None,
};
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))