From 088734f237bd9756b8d1672c17b8ae5e905dfd69 Mon Sep 17 00:00:00 2001 From: Matthias Lodner Date: Sat, 7 Feb 2026 19:08:13 +0100 Subject: [PATCH] Added topm id and row number and ui changes. --- common/src/models/article.rs | 9 +- common/src/models/variant.rs | 8 +- frontend/app/components/article/article.vue | 12 ++ .../app/components/article/articleCreate.vue | 19 ++- .../app/components/variant/variantCreate.vue | 54 ++++++-- .../app/components/variant/variantRow.vue | 125 ++++++++++-------- frontend/app/store/labelEditorStore.ts | 1 + frontend/app/types/article.ts | 6 +- frontend/app/types/variant.ts | 4 +- .../migrations/20260207152836_topm_id_row.sql | 7 + server/src/main.rs | 5 + 11 files changed, 176 insertions(+), 74 deletions(-) create mode 100644 server/migrations/20260207152836_topm_id_row.sql diff --git a/common/src/models/article.rs b/common/src/models/article.rs index 3f4ffc0..d3cfb8f 100644 --- a/common/src/models/article.rs +++ b/common/src/models/article.rs @@ -21,6 +21,7 @@ pub struct Article { pub bio_origin: Option, pub allergens_text: Option, pub bio_info: Option, + pub topm_id: Option, } 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
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", ); diff --git a/common/src/models/variant.rs b/common/src/models/variant.rs index cfa274d..45821e5 100644 --- a/common/src/models/variant.rs +++ b/common/src/models/variant.rs @@ -16,6 +16,7 @@ pub struct Variant { pub unit: Unit, pub label: Option