Added settings override fields to article.
This commit is contained in:
@@ -17,6 +17,10 @@ pub struct Article {
|
|||||||
pub ingredients: Option<String>,
|
pub ingredients: Option<String>,
|
||||||
pub default_unit: Unit,
|
pub default_unit: Unit,
|
||||||
pub variants: Vec<Variant>,
|
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 {
|
fn from_postgres_row_small(row: PgRow) -> Article {
|
||||||
@@ -29,6 +33,10 @@ fn from_postgres_row_small(row: PgRow) -> Article {
|
|||||||
ingredients: row.get(5),
|
ingredients: row.get(5),
|
||||||
default_unit: row.get(6),
|
default_unit: row.get(6),
|
||||||
variants: vec![],
|
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),
|
ingredients: row.get(5),
|
||||||
default_unit: row.get(6),
|
default_unit: row.get(6),
|
||||||
variants: variants,
|
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.description);
|
||||||
args.add(&article.ingredients);
|
args.add(&article.ingredients);
|
||||||
args.add(&article.default_unit);
|
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!(
|
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",
|
"article",
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -156,9 +172,13 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
|
|||||||
args.add(&article.description);
|
args.add(&article.description);
|
||||||
args.add(&article.ingredients);
|
args.add(&article.ingredients);
|
||||||
args.add(&article.default_unit);
|
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!(
|
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",
|
"article",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<v-container>
|
<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-card-title>
|
||||||
<v-row style="padding-top: 10px">
|
<v-row style="padding-top: 10px">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
@@ -126,15 +126,15 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row no-gutters>
|
<v-row no-gutters>
|
||||||
<v-col cols="5">
|
<v-select
|
||||||
Herkunft:
|
v-model="store.articleEdit.origin"
|
||||||
</v-col>
|
:items="store.origins"
|
||||||
<v-col>
|
label="Herkunft"
|
||||||
{{ originToString(store.article.origin) }}
|
:readonly="!edit"
|
||||||
</v-col>
|
></v-select>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row>
|
<v-row no-gutters>
|
||||||
<v-select
|
<v-select
|
||||||
v-model="store.articleEdit.default_unit"
|
v-model="store.articleEdit.default_unit"
|
||||||
:items="store.units"
|
:items="store.units"
|
||||||
@@ -142,9 +142,39 @@
|
|||||||
:readonly="!edit"
|
:readonly="!edit"
|
||||||
></v-select>
|
></v-select>
|
||||||
</v-row>
|
</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>
|
||||||
|
|
||||||
<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.bio_info"
|
||||||
|
label="BIO Hinweis Text"
|
||||||
|
:hint="store.settings.bio_info"
|
||||||
|
persistent-placeholder
|
||||||
|
persistent-hint
|
||||||
|
/>
|
||||||
|
</v-row>
|
||||||
|
<v-row no-gutters>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model.trim="store.articleEdit.description"
|
v-model.trim="store.articleEdit.description"
|
||||||
:tile=true
|
:tile=true
|
||||||
@@ -160,9 +190,20 @@
|
|||||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||||
</template>
|
</template>
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
|
</v-row>
|
||||||
</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.allergens_text"
|
||||||
|
label="Allergen Hinweis"
|
||||||
|
:hint="store.settings.allergens_text"
|
||||||
|
persistent-placeholder
|
||||||
|
persistent-hint
|
||||||
|
/>
|
||||||
|
</v-row>
|
||||||
|
<v-row no-gutters>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model.trim="store.articleEdit.ingredients"
|
v-model.trim="store.articleEdit.ingredients"
|
||||||
:tile=true
|
:tile=true
|
||||||
@@ -178,6 +219,7 @@
|
|||||||
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
<span>{{ counter }} von {{ store.ingredientsMaxChars }} Zeichen.</span>
|
||||||
</template>
|
</template>
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
let default_unit: Ref<Unit | null> = ref<Unit | null>(null);
|
let default_unit: Ref<Unit | null> = ref<Unit | null>(null);
|
||||||
let description: Ref<string | null> = ref<string | null>(null);
|
let description: Ref<string | null> = ref<string | null>(null);
|
||||||
let ingredients: 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() {
|
async function create() {
|
||||||
if (name.value != null && name.value.trim().length > 0 &&
|
if (name.value != null && name.value.trim().length > 0 &&
|
||||||
@@ -24,7 +28,9 @@
|
|||||||
) {
|
) {
|
||||||
loading.value = true;
|
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);
|
await store.createArticle(article);
|
||||||
|
|
||||||
@@ -43,6 +49,10 @@
|
|||||||
origin.value = null;
|
origin.value = null;
|
||||||
description.value = null;
|
description.value = null;
|
||||||
ingredients.value = null;
|
ingredients.value = null;
|
||||||
|
mhd.value = null;
|
||||||
|
bio_origin.value = null;
|
||||||
|
allergens_text.value = null;
|
||||||
|
bio_info.value = null;
|
||||||
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
@@ -71,7 +81,7 @@
|
|||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-card>
|
<v-card v-if="store.settings != null">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<v-icon size="small">
|
<v-icon size="small">
|
||||||
mdi-plus-thick
|
mdi-plus-thick
|
||||||
@@ -123,6 +133,40 @@
|
|||||||
v-model.trim="ingredients"
|
v-model.trim="ingredients"
|
||||||
label="Zutaten"
|
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-card-text>
|
||||||
|
|
||||||
<v-divider/>
|
<v-divider/>
|
||||||
|
|||||||
@@ -286,6 +286,10 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
|||||||
this.article.origin = updatedArticle.origin;
|
this.article.origin = updatedArticle.origin;
|
||||||
this.article.description = updatedArticle.description;
|
this.article.description = updatedArticle.description;
|
||||||
this.article.ingredients = updatedArticle.ingredients;
|
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');
|
this.addNotification(false, 'Artikel "' + article.name + '" aktualisiert');
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -11,8 +11,15 @@ export class Article {
|
|||||||
ingredients: string | null;
|
ingredients: string | null;
|
||||||
default_unit: Unit;
|
default_unit: Unit;
|
||||||
variants: Array<Variant>;
|
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.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.bio = bio;
|
this.bio = bio;
|
||||||
@@ -26,5 +33,10 @@ export class Article {
|
|||||||
} else {
|
} else {
|
||||||
this.variants = variants;
|
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,
|
ingredients: None,
|
||||||
default_unit: Unit::G,
|
default_unit: Unit::G,
|
||||||
variants: vec![],
|
variants: vec![],
|
||||||
|
mhd: None,
|
||||||
|
bio_origin: None,
|
||||||
|
allergens_text: None,
|
||||||
|
bio_info: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||||
@@ -142,6 +146,10 @@ async fn create_article(
|
|||||||
ingredients: None,
|
ingredients: None,
|
||||||
default_unit: Unit::G,
|
default_unit: Unit::G,
|
||||||
variants: vec![],
|
variants: vec![],
|
||||||
|
mhd: None,
|
||||||
|
bio_origin: None,
|
||||||
|
allergens_text: None,
|
||||||
|
bio_info: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||||
@@ -172,6 +180,10 @@ async fn update_article_route(
|
|||||||
ingredients: None,
|
ingredients: None,
|
||||||
default_unit: Unit::G,
|
default_unit: Unit::G,
|
||||||
variants: vec![],
|
variants: vec![],
|
||||||
|
mhd: None,
|
||||||
|
bio_origin: None,
|
||||||
|
allergens_text: None,
|
||||||
|
bio_info: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
(StatusCode::INTERNAL_SERVER_ERROR, Json(article))
|
||||||
|
|||||||
Reference in New Issue
Block a user