2021-03-17 21:49:23 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<q-dialog v-model="edittype">
|
|
|
|
<q-card>
|
|
|
|
<q-card-section>
|
|
|
|
<div class="text-h6">Editere Extrazutaten {{ actualExtraIngredient.name }}</div>
|
|
|
|
</q-card-section>
|
|
|
|
<q-card-section>
|
2021-03-19 15:33:27 +00:00
|
|
|
<q-input v-model="actualExtraIngredient.name" dense label="Name" filled />
|
2021-03-17 21:49:23 +00:00
|
|
|
<q-input
|
2021-03-19 15:33:27 +00:00
|
|
|
v-model.number="actualExtraIngredient.price"
|
2021-03-17 21:49:23 +00:00
|
|
|
dense
|
|
|
|
label="Preis"
|
|
|
|
filled
|
|
|
|
type="number"
|
|
|
|
min="0"
|
|
|
|
step="0.1"
|
|
|
|
suffix="€"
|
|
|
|
/>
|
|
|
|
</q-card-section>
|
|
|
|
<q-card-actions>
|
|
|
|
<q-btn flat color="danger" label="Abbrechen" @click="discardChanges()" />
|
|
|
|
<q-btn flat color="primary" label="Speichern" @click="saveChanges()" />
|
|
|
|
</q-card-actions>
|
|
|
|
</q-card>
|
|
|
|
</q-dialog>
|
|
|
|
|
|
|
|
<q-page padding>
|
2021-03-19 19:41:21 +00:00
|
|
|
<q-table title="Getränkearten" :rows="rows" :row-key="(row) => row.id" :columns="columns">
|
2021-03-19 15:33:27 +00:00
|
|
|
<template #top-right>
|
2021-04-17 11:58:27 +00:00
|
|
|
<div class="full-width row q-gutter-sm">
|
|
|
|
<q-input
|
|
|
|
v-model="newExtraIngredient.name"
|
|
|
|
dense
|
|
|
|
placeholder="Neue Zutatenbezeichnung"
|
|
|
|
label="Neue Zutatenbezeichnung"
|
|
|
|
filled
|
|
|
|
/>
|
|
|
|
<q-input
|
|
|
|
v-model.number="newExtraIngredient.price"
|
|
|
|
dense
|
|
|
|
placeholder="Preis"
|
|
|
|
label="Preis"
|
|
|
|
filled
|
|
|
|
type="number"
|
|
|
|
min="0"
|
|
|
|
step="0.1"
|
|
|
|
suffix="€"
|
|
|
|
/>
|
|
|
|
<q-btn color="primary" icon="mdi-plus" round @click="addExtraIngredient">
|
|
|
|
<q-tooltip> Zutat hinzufügen </q-tooltip>
|
|
|
|
</q-btn>
|
|
|
|
</div>
|
2021-03-17 21:49:23 +00:00
|
|
|
</template>
|
2021-04-17 11:58:27 +00:00
|
|
|
<template #body="props">
|
|
|
|
<q-tr :props="props">
|
|
|
|
<q-td key="name" :props="props" align="left">
|
|
|
|
{{ props.row.name }}
|
|
|
|
<q-popup-edit
|
|
|
|
v-model="props.row.name"
|
|
|
|
buttons
|
|
|
|
label-set="Speichern"
|
|
|
|
label-cancel="Abbrechen"
|
|
|
|
@save="saveChanges(props.row)"
|
|
|
|
>
|
|
|
|
<template #default="scope">
|
|
|
|
<q-input v-model="scope.value" dense label="name" filled />
|
|
|
|
</template>
|
|
|
|
</q-popup-edit>
|
|
|
|
</q-td>
|
|
|
|
<q-td key="price" :props="props" align="right">
|
|
|
|
{{ props.row.price.toFixed(2) }}€
|
|
|
|
</q-td>
|
|
|
|
<q-td key="actions" :props="props" align="right" auto-width>
|
|
|
|
<q-btn
|
|
|
|
round
|
|
|
|
icon="mdi-delete"
|
|
|
|
color="negative"
|
|
|
|
size="sm"
|
|
|
|
@click="deleteType(props.row)"
|
|
|
|
/>
|
|
|
|
</q-td>
|
|
|
|
</q-tr>
|
2021-03-17 21:49:23 +00:00
|
|
|
</template>
|
|
|
|
</q-table>
|
|
|
|
</q-page>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-03-20 21:16:37 +00:00
|
|
|
import { computed, ComputedRef, defineComponent, ref } from 'vue';
|
|
|
|
import { usePricelistStore } from 'src/plugins/pricelist/store';
|
2021-03-17 21:49:23 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'DrinkTypes',
|
2021-03-19 15:33:27 +00:00
|
|
|
setup() {
|
2021-03-20 21:16:37 +00:00
|
|
|
const store = usePricelistStore();
|
2021-03-17 21:49:23 +00:00
|
|
|
const emptyExtraIngredient: FG.ExtraIngredient = {
|
|
|
|
name: '',
|
|
|
|
price: 0,
|
2021-03-18 16:23:57 +00:00
|
|
|
id: -1,
|
2021-03-17 21:49:23 +00:00
|
|
|
};
|
2021-03-19 19:41:21 +00:00
|
|
|
const newExtraIngredient = ref<FG.ExtraIngredient>(emptyExtraIngredient);
|
2021-03-17 21:49:23 +00:00
|
|
|
|
2021-03-19 19:41:21 +00:00
|
|
|
const rows = computed(() => store.extraIngredients);
|
2021-03-17 21:49:23 +00:00
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
name: 'name',
|
|
|
|
label: 'Bezeichnung',
|
|
|
|
field: 'name',
|
|
|
|
align: 'left',
|
2021-03-18 16:23:57 +00:00
|
|
|
sortable: true,
|
2021-03-17 21:49:23 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'price',
|
|
|
|
label: 'Preis',
|
|
|
|
field: 'price',
|
|
|
|
sortable: true,
|
2021-03-18 16:23:57 +00:00
|
|
|
format: (val: number) => `${val.toFixed(2)}€`,
|
2021-04-17 11:58:27 +00:00
|
|
|
align: 'right',
|
2021-03-17 21:49:23 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'actions',
|
|
|
|
label: 'Aktionen',
|
|
|
|
field: 'actions',
|
2021-03-18 16:23:57 +00:00
|
|
|
align: 'right',
|
|
|
|
},
|
2021-03-17 21:49:23 +00:00
|
|
|
];
|
|
|
|
|
2021-03-19 19:41:21 +00:00
|
|
|
async function addExtraIngredient() {
|
|
|
|
await store.setExtraIngredient((<ComputedRef>newExtraIngredient).value);
|
2021-03-21 21:07:12 +00:00
|
|
|
newExtraIngredient.value = Object.assign({}, emptyExtraIngredient);
|
|
|
|
discardChanges();
|
2021-03-17 21:49:23 +00:00
|
|
|
}
|
|
|
|
|
2021-04-17 11:58:27 +00:00
|
|
|
function saveChanges(ingredient: FG.ExtraIngredient) {
|
|
|
|
setTimeout(() => {
|
|
|
|
const _ingredient = store.extraIngredients.find((a) => a.id === ingredient.id);
|
|
|
|
if (_ingredient) {
|
|
|
|
void store.updateExtraIngredient(_ingredient);
|
|
|
|
}
|
|
|
|
}, 50);
|
2021-03-17 21:49:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function discardChanges() {
|
2021-03-21 21:07:12 +00:00
|
|
|
newExtraIngredient.value.name = '';
|
|
|
|
newExtraIngredient.value.price = 0;
|
2021-03-17 21:49:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteType(extraIngredient: FG.ExtraIngredient) {
|
2021-03-19 19:41:21 +00:00
|
|
|
void store.deleteExtraIngredient(extraIngredient);
|
2021-03-17 21:49:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
columns,
|
|
|
|
rows,
|
|
|
|
addExtraIngredient,
|
|
|
|
newExtraIngredient,
|
|
|
|
deleteType,
|
|
|
|
discardChanges,
|
2021-03-18 16:23:57 +00:00
|
|
|
saveChanges,
|
2021-03-19 19:41:21 +00:00
|
|
|
};
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2021-03-17 21:49:23 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|