Added additional values to settings.

This commit is contained in:
2026-02-02 18:25:06 +01:00
parent c34b2391eb
commit 544b6ee5fc
5 changed files with 53 additions and 11 deletions
+7 -1
View File
@@ -8,6 +8,8 @@ pub struct Settings {
pub id: i64, pub id: i64,
pub mhd: String, pub mhd: String,
pub bio: String, pub bio: String,
pub allergens_text: String,
pub bio_info: String,
} }
fn from_postgres_row_small(row: PgRow) -> Settings { fn from_postgres_row_small(row: PgRow) -> Settings {
@@ -15,6 +17,8 @@ fn from_postgres_row_small(row: PgRow) -> Settings {
id: row.get(0), id: row.get(0),
mhd: row.get(1), mhd: row.get(1),
bio: row.get(2), bio: row.get(2),
allergens_text: row.get(3),
bio_info: row.get(4),
} }
} }
@@ -44,9 +48,11 @@ pub async fn update_settings(settings: &Settings, pool: PgPool) -> Option<Settin
args.add(&settings.id); args.add(&settings.id);
args.add(&settings.mhd); args.add(&settings.mhd);
args.add(&settings.bio); args.add(&settings.bio);
args.add(&settings.allergens_text);
args.add(&settings.bio_info);
let statement = format!( let statement = format!(
"UPDATE {} SET mhd = $2, bio = $3 WHERE id = $1 RETURNING *", "UPDATE {} SET mhd = $2, bio = $3, allergens_text = $4, bio_info = $5 WHERE id = $1 RETURNING *",
"settings", "settings",
); );
+27 -9
View File
@@ -5,6 +5,7 @@
import DeleteConfirm from "~/components/ui/deleteConfirm.vue"; import DeleteConfirm from "~/components/ui/deleteConfirm.vue";
import {Label} from "~/types/label"; import {Label} from "~/types/label";
import {Settings} from "~/types/settings"; import {Settings} from "~/types/settings";
import SettingsRow from "~/components/settings/settingsRow.vue";
let store = useLabelEditorStore(); let store = useLabelEditorStore();
let dialog: Ref<boolean> = ref<boolean>(false); let dialog: Ref<boolean> = ref<boolean>(false);
@@ -25,15 +26,23 @@
switch (name) { switch (name) {
case "MHD": case "MHD":
console.log("Update MHD: " + value); console.log("Update MHD: " + value);
const settingsMhd = new Settings(store.settings.id, value, store.settings.bio); const settingsMhd = new Settings(store.settings.id, value, store.settings.bio, store.settings.allergens_text, store.settings.bio_info);
await store.updateSettings(settingsMhd); await store.updateSettings(settingsMhd);
break; break;
case "BIO": case "BIO":
console.log("Update BIO: " + value); console.log("Update BIO: " + value);
const settingsBio = new Settings(store.settings.id, store.settings.mhd, value); const settingsBio = new Settings(store.settings.id, store.settings.mhd, value, store.settings.allergens_text, store.settings.bio_info);
await store.updateSettings(settingsBio); await store.updateSettings(settingsBio);
break;
case "Allergen Hinweis":
console.log("Update Allergen Text: " + value);
const settingsAllergens = new Settings(store.settings.id, store.settings.mhd, store.settings.bio, value, store.settings.bio_info);
await store.updateSettings(settingsAllergens);
break;
case "BIO Hinweis":
console.log("Update Allergen Text: " + value);
const settingsBioInfo = new Settings(store.settings.id, store.settings.mhd, store.settings.bio, store.settings.allergens_text, value);
await store.updateSettings(settingsBioInfo);
break; break;
default: default:
console.log("Error: Unbekannter Wert für Einstellungen"); console.log("Error: Unbekannter Wert für Einstellungen");
@@ -80,11 +89,6 @@
Einstellungen Einstellungen
<v-progress-circular v-if="loading" indeterminate :size="15" :width="2"></v-progress-circular> <v-progress-circular v-if="loading" indeterminate :size="15" :width="2"></v-progress-circular>
<v-spacer/>
<v-divider vertical/>
<LabelCreate/>
</v-row> </v-row>
</v-card-title> </v-card-title>
@@ -104,6 +108,20 @@
v-bind:value="store.settings.bio" v-bind:value="store.settings.bio"
@update="updateSettings" @update="updateSettings"
/> />
<SettingsRow
key="bio_info"
name="BIO Hinweis"
v-bind:value="store.settings.bio_info"
@update="updateSettings"
/>
<SettingsRow
key="allergens"
name="Allergen Hinweis"
v-bind:value="store.settings.allergens_text"
@update="updateSettings"
/>
</v-card-text> </v-card-text>
<v-card-text v-else> <v-card-text v-else>
+5 -1
View File
@@ -2,10 +2,14 @@ export class Settings {
readonly id: number; readonly id: number;
mhd: string; mhd: string;
bio: string; bio: string;
allergens_text: string;
bio_info: string;
constructor(id: number, mhd: string, bio: string) { constructor(id: number, mhd: string, bio: string, allergens_text: string, bio_info: string) {
this.id = id; this.id = id;
this.mhd = mhd; this.mhd = mhd;
this.bio = bio; this.bio = bio;
this.allergens_text = allergens_text;
this.bio_info = bio_info;
} }
} }
@@ -0,0 +1,10 @@
-- Add migration script here
ALTER TABLE public.settings
ADD allergens_text text,
ADD bio_info text;
UPDATE settings SET
allergens_text = 'Produkt kann Spuren von Erdnüssen, Gluten, Krebstieren, Lupinen, Schalenfrüchte, Sesam, Soja und Weichtieren enthalten.',
bio_info = '+aus kontrolliert biologischem Anbau.'
WHERE id = 1;
+4
View File
@@ -373,6 +373,8 @@ async fn get_settings_route(
id: 0, id: 0,
mhd: "".to_string(), mhd: "".to_string(),
bio: "".to_string(), bio: "".to_string(),
allergens_text: "".to_string(),
bio_info: "".to_string(),
} }
)) ))
} }
@@ -396,6 +398,8 @@ async fn update_settings_route(
id: 0, id: 0,
mhd: "".to_string(), mhd: "".to_string(),
bio: "".to_string(), bio: "".to_string(),
allergens_text: "".to_string(),
bio_info: "".to_string(),
} }
)) ))
} }