201 lines
5.0 KiB
Vue
201 lines
5.0 KiB
Vue
<script setup lang="ts">
|
|
import type {Ref} from "vue";
|
|
import {useLabelEditorStore} from "~/store/labelEditorStore";
|
|
import {Article} from "~/types/article";
|
|
import {Origin} from "~/types/origin";
|
|
import type {Unit} from "~/types/unit";
|
|
|
|
let store = useLabelEditorStore();
|
|
|
|
let dialog: Ref<boolean> = ref<boolean>(false);
|
|
let loading: Ref<boolean> = ref<boolean>(false);
|
|
|
|
let name: Ref<string | null> = ref<string | null>(null);
|
|
let bio: Ref<boolean> = ref<boolean>(false);
|
|
let origin: Ref<Origin | null> = ref<Origin | null>(null);
|
|
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 &&
|
|
origin.value != null && origin.value.trim().length > 0 &&
|
|
default_unit.value != null && default_unit.value.trim().length > 0
|
|
) {
|
|
loading.value = true;
|
|
|
|
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);
|
|
|
|
closeDialog();
|
|
}
|
|
}
|
|
|
|
function closeDialog() {
|
|
dialog.value = false;
|
|
clearVariables();
|
|
}
|
|
|
|
function clearVariables() {
|
|
name.value = null;
|
|
bio.value = false;
|
|
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;
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<v-dialog
|
|
v-model="dialog"
|
|
:scrollable="true"
|
|
width="800"
|
|
max-height="750"
|
|
>
|
|
<template v-slot:activator="{ props }">
|
|
<v-btn
|
|
:flat="true"
|
|
v-bind="props"
|
|
size="small"
|
|
>
|
|
<v-icon>mdi-plus-thick</v-icon>
|
|
<v-tooltip
|
|
activator="parent"
|
|
location="bottom"
|
|
>
|
|
Erstellen
|
|
</v-tooltip>
|
|
</v-btn>
|
|
</template>
|
|
|
|
<v-card v-if="store.settings != null">
|
|
<v-card-title>
|
|
<v-icon size="small">
|
|
mdi-plus-thick
|
|
</v-icon>
|
|
|
|
Artikel erstellen
|
|
|
|
<v-progress-circular v-if="loading" indeterminate :size="15" :width="2"></v-progress-circular>
|
|
</v-card-title>
|
|
|
|
<v-divider/>
|
|
|
|
<v-card-text>
|
|
<v-text-field
|
|
v-model.trim="name"
|
|
label="Bezeichnung"
|
|
autofocus
|
|
/>
|
|
|
|
<v-row>
|
|
<v-col cols="2">
|
|
<v-checkbox
|
|
v-model="bio"
|
|
label="BIO"
|
|
/>
|
|
</v-col>
|
|
<v-col>
|
|
<v-select
|
|
v-model="origin"
|
|
:items="store.origins"
|
|
label="Herkunft"
|
|
></v-select>
|
|
</v-col>
|
|
<v-col>
|
|
<v-select
|
|
v-model="default_unit"
|
|
:items="store.units"
|
|
label="Standard Einheit"
|
|
></v-select>
|
|
</v-col>
|
|
</v-row>
|
|
|
|
<v-textarea
|
|
v-model.trim="description"
|
|
label="Beschreibung"
|
|
/>
|
|
|
|
<v-textarea
|
|
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/>
|
|
|
|
<v-card-actions>
|
|
<v-spacer/>
|
|
|
|
<v-btn
|
|
variant="text"
|
|
:disabled="loading"
|
|
@click="closeDialog()"
|
|
>
|
|
Abbrechen
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
variant="text"
|
|
:disabled="name == null ||
|
|
origin == null ||
|
|
loading"
|
|
@click="create();"
|
|
>
|
|
Erstellen
|
|
</v-btn>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</v-dialog>
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
</style> |