Added settings override fields to article.
This commit is contained in:
@@ -17,6 +17,10 @@ pub struct Article {
|
||||
pub ingredients: Option<String>,
|
||||
pub default_unit: Unit,
|
||||
pub variants: Vec<Variant>,
|
||||
pub mhd: Option<String>,
|
||||
pub bio_origin: Option<String>,
|
||||
pub allergens_text: Option<String>,
|
||||
pub bio_info: Option<String>,
|
||||
}
|
||||
|
||||
fn from_postgres_row_small(row: PgRow) -> Article {
|
||||
@@ -29,6 +33,10 @@ fn from_postgres_row_small(row: PgRow) -> Article {
|
||||
ingredients: row.get(5),
|
||||
default_unit: row.get(6),
|
||||
variants: vec![],
|
||||
mhd: row.get(7),
|
||||
bio_origin: row.get(8),
|
||||
allergens_text: row.get(9),
|
||||
bio_info: row.get(10),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +63,10 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article {
|
||||
ingredients: row.get(5),
|
||||
default_unit: row.get(6),
|
||||
variants: variants,
|
||||
mhd: row.get(7),
|
||||
bio_origin: row.get(8),
|
||||
allergens_text: row.get(9),
|
||||
bio_info: row.get(10),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,9 +133,13 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
|
||||
args.add(&article.description);
|
||||
args.add(&article.ingredients);
|
||||
args.add(&article.default_unit);
|
||||
args.add(&article.mhd);
|
||||
args.add(&article.bio_origin);
|
||||
args.add(&article.allergens_text);
|
||||
args.add(&article.bio_info);
|
||||
|
||||
let statement = format!(
|
||||
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id) VALUES ($1, $2, $3, $4, $5, $6) RETURNING *",
|
||||
"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 *",
|
||||
"article",
|
||||
);
|
||||
|
||||
@@ -156,9 +172,13 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
|
||||
args.add(&article.description);
|
||||
args.add(&article.ingredients);
|
||||
args.add(&article.default_unit);
|
||||
args.add(&article.mhd);
|
||||
args.add(&article.bio_origin);
|
||||
args.add(&article.allergens_text);
|
||||
args.add(&article.bio_info);
|
||||
|
||||
let statement = format!(
|
||||
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7 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 WHERE id = $1 RETURNING *",
|
||||
"article",
|
||||
);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<template>
|
||||
<v-container>
|
||||
<v-card v-if="store.article != null && store.articleEdit != null">
|
||||
<v-card v-if="store.article != null && store.articleEdit != null && store.settings != null">
|
||||
<v-card-title>
|
||||
<v-row style="padding-top: 10px">
|
||||
<v-text-field
|
||||
@@ -126,15 +126,15 @@
|
||||
</v-row>
|
||||
|
||||
<v-row no-gutters>
|
||||
<v-col cols="5">
|
||||
Herkunft:
|
||||
</v-col>
|
||||
<v-col>
|
||||
{{ originToString(store.article.origin) }}
|
||||
</v-col>
|
||||
<v-select
|
||||
v-model="store.articleEdit.origin"
|
||||
:items="store.origins"
|
||||
label="Herkunft"
|
||||
:readonly="!edit"
|
||||
></v-select>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-row no-gutters>
|
||||
<v-select
|
||||
v-model="store.articleEdit.default_unit"
|
||||
:items="store.units"
|
||||
@@ -142,42 +142,84 @@
|
||||
:readonly="!edit"
|
||||
></v-select>
|
||||
</v-row>
|
||||
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="store.articleEdit.bio_origin"
|
||||
label="BIO Hinweis Text"
|
||||
:hint="store.settings.bio"
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
/>
|
||||
</v-row>
|
||||
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="store.articleEdit.mhd"
|
||||
label="MHD Text"
|
||||
:hint="store.settings.mhd"
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
/>
|
||||
</v-row>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="5" style="padding: 5px;">
|
||||
<v-textarea
|
||||
v-model.trim="store.articleEdit.description"
|
||||
:tile=true
|
||||
label="Beschreibung"
|
||||
counter
|
||||
:persistentCounter=true
|
||||
rows="6"
|
||||
no-resize
|
||||
:readonly="!edit"
|
||||
persistent-placeholder
|
||||
>
|
||||
<template v-slot:counter="{ counter }">
|
||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||
</template>
|
||||
</v-textarea>
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="store.articleEdit.bio_info"
|
||||
label="BIO Hinweis Text"
|
||||
:hint="store.settings.bio_info"
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-textarea
|
||||
v-model.trim="store.articleEdit.description"
|
||||
:tile=true
|
||||
label="Beschreibung"
|
||||
counter
|
||||
:persistentCounter=true
|
||||
rows="6"
|
||||
no-resize
|
||||
:readonly="!edit"
|
||||
persistent-placeholder
|
||||
>
|
||||
<template v-slot:counter="{ counter }">
|
||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||
</template>
|
||||
</v-textarea>
|
||||
</v-row>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="5" style="padding: 5px;">
|
||||
<v-textarea
|
||||
v-model.trim="store.articleEdit.ingredients"
|
||||
:tile=true
|
||||
label="Zutaten"
|
||||
counter
|
||||
:persistentCounter=true
|
||||
rows="6"
|
||||
no-resize
|
||||
:readonly="!edit"
|
||||
persistent-placeholder
|
||||
>
|
||||
<template v-slot:counter="{ counter }">
|
||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||
</template>
|
||||
</v-textarea>
|
||||
<v-row no-gutters>
|
||||
<v-text-field
|
||||
v-model.trim="store.articleEdit.allergens_text"
|
||||
label="Allergen Hinweis"
|
||||
:hint="store.settings.allergens_text"
|
||||
persistent-placeholder
|
||||
persistent-hint
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-textarea
|
||||
v-model.trim="store.articleEdit.ingredients"
|
||||
:tile=true
|
||||
label="Zutaten"
|
||||
counter
|
||||
:persistentCounter=true
|
||||
rows="6"
|
||||
no-resize
|
||||
:readonly="!edit"
|
||||
persistent-placeholder
|
||||
>
|
||||
<template v-slot:counter="{ counter }">
|
||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||
</template>
|
||||
</v-textarea>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
let default_unit: Ref<Unit | null> = ref<Unit | null>(null);
|
||||
let description: Ref<string | null> = ref<string | null>(null);
|
||||
let ingredients: Ref<string | null> = ref<string | null>(null);
|
||||
let mhd: Ref<string | null> = ref<string | null>(null);
|
||||
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);
|
||||
|
||||
async function create() {
|
||||
if (name.value != null && name.value.trim().length > 0 &&
|
||||
@@ -24,7 +28,9 @@
|
||||
) {
|
||||
loading.value = true;
|
||||
|
||||
const article: Article = new Article(0, name.value, bio.value, origin.value, description.value, ingredients.value, default_unit.value, []);
|
||||
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);
|
||||
|
||||
await store.createArticle(article);
|
||||
|
||||
@@ -43,6 +49,10 @@
|
||||
origin.value = null;
|
||||
description.value = null;
|
||||
ingredients.value = null;
|
||||
mhd.value = null;
|
||||
bio_origin.value = null;
|
||||
allergens_text.value = null;
|
||||
bio_info.value = null;
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -71,7 +81,7 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<v-card>
|
||||
<v-card v-if="store.settings != null">
|
||||
<v-card-title>
|
||||
<v-icon size="small">
|
||||
mdi-plus-thick
|
||||
@@ -123,6 +133,40 @@
|
||||
v-model.trim="ingredients"
|
||||
label="Zutaten"
|
||||
/>
|
||||
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model.trim="mhd"
|
||||
label="MHD Text"
|
||||
:hint="store.settings.mhd"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model.trim="allergens_text"
|
||||
label="Allergen Hinweis"
|
||||
:hint="store.settings.allergens_text"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model.trim="bio_origin"
|
||||
label="BIO Prüfstelle"
|
||||
:hint="store.settings.bio"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model.trim="bio_info"
|
||||
label="BIO Info Text"
|
||||
:hint="store.settings.bio_info"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider/>
|
||||
|
||||
@@ -286,6 +286,10 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
||||
this.article.origin = updatedArticle.origin;
|
||||
this.article.description = updatedArticle.description;
|
||||
this.article.ingredients = updatedArticle.ingredients;
|
||||
this.article.mhd = updatedArticle.mhd;
|
||||
this.article.bio_origin = updatedArticle.bio_origin;
|
||||
this.article.bio_info = updatedArticle.bio_info;
|
||||
this.article.allergens_text = updatedArticle.allergens_text;
|
||||
|
||||
this.addNotification(false, 'Artikel "' + article.name + '" aktualisiert');
|
||||
} catch {
|
||||
|
||||
@@ -11,8 +11,15 @@ export class Article {
|
||||
ingredients: string | null;
|
||||
default_unit: Unit;
|
||||
variants: Array<Variant>;
|
||||
mhd: string | null;
|
||||
bio_origin: string | null;
|
||||
allergens_text: string | null;
|
||||
bio_info: string | null;
|
||||
|
||||
constructor(id: number, name: string, bio: boolean, origin: Origin, description: string | null, ingredients: string | null, default_unit: Unit, variants: Array<Variant> | 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) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.bio = bio;
|
||||
@@ -26,5 +33,10 @@ export class Article {
|
||||
} else {
|
||||
this.variants = variants;
|
||||
}
|
||||
|
||||
this.mhd = mhd;
|
||||
this.bio_origin = bio_origin;
|
||||
this.allergens_text = allergens_text;
|
||||
this.bio_info = bio_info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Add migration script here
|
||||
|
||||
ALTER TABLE public.article
|
||||
ADD mhd text,
|
||||
ADD bio_origin text,
|
||||
ADD allergens_text text,
|
||||
ADD bio_info text;
|
||||
@@ -114,6 +114,10 @@ async fn get_article(
|
||||
ingredients: None,
|
||||
default_unit: Unit::G,
|
||||
variants: vec![],
|
||||
mhd: None,
|
||||
bio_origin: None,
|
||||
allergens_text: None,
|
||||
bio_info: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||
@@ -142,6 +146,10 @@ async fn create_article(
|
||||
ingredients: None,
|
||||
default_unit: Unit::G,
|
||||
variants: vec![],
|
||||
mhd: None,
|
||||
bio_origin: None,
|
||||
allergens_text: None,
|
||||
bio_info: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||
@@ -172,6 +180,10 @@ async fn update_article_route(
|
||||
ingredients: None,
|
||||
default_unit: Unit::G,
|
||||
variants: vec![],
|
||||
mhd: None,
|
||||
bio_origin: None,
|
||||
allergens_text: None,
|
||||
bio_info: None,
|
||||
};
|
||||
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||
|
||||
Reference in New Issue
Block a user