From ae5212bbfc288f7b3c5d5295e815be1396c85097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sat, 17 Apr 2021 13:40:03 +0200 Subject: [PATCH] [pricelist] clean style drinkType --- .../pricelist/components/CalculationTable.vue | 9 +- .../pricelist/components/DrinkTypes.vue | 90 ++++++++----------- 2 files changed, 39 insertions(+), 60 deletions(-) diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index 7254725..334ee73 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -33,10 +33,7 @@ - @@ -50,10 +53,6 @@ export default defineComponent({ setup() { const store = usePricelistStore(); const newDrinkType = ref(''); - const newDrinkTypeName = ref(''); - const edittype = ref(false); - const emptyDrinkType: FG.DrinkType = { id: -1, name: '' }; - const actualDrinkType = ref(emptyDrinkType); onBeforeMount(() => { void store.getDrinkTypes(true); @@ -80,25 +79,13 @@ export default defineComponent({ newDrinkType.value = ''; } - function editType(drinkType: FG.DrinkType) { - edittype.value = true; - actualDrinkType.value = drinkType; - } - - async function saveChanges() { - try { - await store.changeDrinkTypeName({ - id: actualDrinkType.value.id, - name: newDrinkTypeName.value, - }); - } catch (e) {} - discardChanges(); - } - - function discardChanges() { - actualDrinkType.value = emptyDrinkType; - newDrinkTypeName.value = ''; - edittype.value = false; + function saveChanges(drinkType: FG.DrinkType) { + setTimeout(() => { + const _drinkType = store.drinkTypes.find((a) => a.id === drinkType.id); + if (_drinkType) { + void store.changeDrinkTypeName(drinkType); + } + }, 50); } function deleteType(id: number) { @@ -111,11 +98,6 @@ export default defineComponent({ addType, newDrinkType, deleteType, - edittype, - editType, - actualDrinkType, - newDrinkTypeName, - discardChanges, saveChanges, }; },