Added additional name filed to article.
This commit is contained in:
@@ -22,6 +22,7 @@ pub struct Article {
|
|||||||
pub allergens_text: Option<String>,
|
pub allergens_text: Option<String>,
|
||||||
pub bio_info: Option<String>,
|
pub bio_info: Option<String>,
|
||||||
pub topm_id: Option<String>,
|
pub topm_id: Option<String>,
|
||||||
|
pub additional_name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_postgres_row_small(row: PgRow) -> Article {
|
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),
|
allergens_text: row.get(9),
|
||||||
bio_info: row.get(10),
|
bio_info: row.get(10),
|
||||||
topm_id: row.get(11),
|
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),
|
allergens_text: row.get(9),
|
||||||
bio_info: row.get(10),
|
bio_info: row.get(10),
|
||||||
topm_id: row.get(11),
|
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.allergens_text);
|
||||||
args.add(&article.bio_info);
|
args.add(&article.bio_info);
|
||||||
args.add(&article.topm_id);
|
args.add(&article.topm_id);
|
||||||
|
args.add(&article.additional_name);
|
||||||
|
|
||||||
let statement = format!(
|
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",
|
"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.allergens_text);
|
||||||
args.add(&article.bio_info);
|
args.add(&article.bio_info);
|
||||||
args.add(&article.topm_id);
|
args.add(&article.topm_id);
|
||||||
|
args.add(&article.additional_name);
|
||||||
|
|
||||||
let statement = format!(
|
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",
|
"article",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -176,6 +176,18 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="5" style="padding: 5px;">
|
<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-row no-gutters>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model.trim="store.articleEdit.bio_info"
|
v-model.trim="store.articleEdit.bio_info"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
let allergens_text: 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 bio_info: Ref<string | null> = ref<string | null>(null);
|
||||||
let topm_id: 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() {
|
async function create() {
|
||||||
if (name.value != null && name.value.trim().length > 0 &&
|
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,
|
const article: Article = new Article(0, name.value, bio.value, origin.value, description.value,
|
||||||
ingredients.value, default_unit.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);
|
await store.createArticle(article);
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
allergens_text.value = null;
|
allergens_text.value = null;
|
||||||
bio_info.value = null;
|
bio_info.value = null;
|
||||||
topm_id.value = null;
|
topm_id.value = null;
|
||||||
|
additional_name.value = null;
|
||||||
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
@@ -108,6 +110,15 @@
|
|||||||
autofocus
|
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-row>
|
||||||
<v-col cols="2">
|
<v-col cols="2">
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
|
|||||||
@@ -183,6 +183,10 @@
|
|||||||
:readonly="!edit"
|
:readonly="!edit"
|
||||||
label="Produkt Bezeichnung"
|
label="Produkt Bezeichnung"
|
||||||
:clearable="edit"
|
:clearable="edit"
|
||||||
|
:placeholder="store.articleEdit.name"
|
||||||
|
:hint="store.articleEdit.name"
|
||||||
|
persistent-placeholder
|
||||||
|
:persistent-hint="store.articleEdit.additional_name != null"
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ export class Article {
|
|||||||
allergens_text: string | null;
|
allergens_text: string | null;
|
||||||
bio_info: string | null;
|
bio_info: string | null;
|
||||||
topm_id: string | null;
|
topm_id: string | null;
|
||||||
|
additional_name: string | null;
|
||||||
|
|
||||||
constructor(id: number, name: string, bio: boolean, origin: Origin, description: string | null,
|
constructor(id: number, name: string, bio: boolean, origin: Origin, description: string | null,
|
||||||
ingredients: string | null, default_unit: Unit, variants: Array<Variant> | null,
|
ingredients: string | null, default_unit: Unit, variants: Array<Variant> | null,
|
||||||
mhd: string | null, bio_origin: string | null, allergens_text: string | 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.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.bio = bio;
|
this.bio = bio;
|
||||||
@@ -40,5 +41,6 @@ export class Article {
|
|||||||
this.allergens_text = allergens_text;
|
this.allergens_text = allergens_text;
|
||||||
this.bio_info = bio_info;
|
this.bio_info = bio_info;
|
||||||
this.topm_id = topm_id;
|
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
@@ -119,6 +119,7 @@ async fn get_article(
|
|||||||
allergens_text: None,
|
allergens_text: None,
|
||||||
bio_info: None,
|
bio_info: None,
|
||||||
topm_id: None,
|
topm_id: None,
|
||||||
|
additional_name: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||||
@@ -152,6 +153,7 @@ async fn create_article(
|
|||||||
allergens_text: None,
|
allergens_text: None,
|
||||||
bio_info: None,
|
bio_info: None,
|
||||||
topm_id: None,
|
topm_id: None,
|
||||||
|
additional_name: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||||
@@ -186,7 +188,8 @@ async fn update_article_route(
|
|||||||
bio_origin: None,
|
bio_origin: None,
|
||||||
allergens_text: None,
|
allergens_text: None,
|
||||||
bio_info: None,
|
bio_info: None,
|
||||||
topm_id: None
|
topm_id: None,
|
||||||
|
additional_name: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||||
|
|||||||
Reference in New Issue
Block a user