From d42c6dcce1ab5cb84130ff6c0e9787d8789dbd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 25 Mar 2021 23:14:49 +0100 Subject: [PATCH 01/51] [pricelist] delete drink pictures --- .../pricelist/components/CalculationTable.vue | 63 +++++++++++++------ .../pricelist/components/DrinkTypes.vue | 12 ++-- src/plugins/pricelist/store.ts | 5 ++ 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index 6632499..5e26945 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -59,23 +59,34 @@ @click="deleteDrink(drinks_props.row)" /> - + - - - - + + @@ -446,20 +457,31 @@ export default defineComponent({ }); drinkPic.value = undefined; } - + interface Row extends Drink { + expand: boolean; + } function savePicture(drink: Drink) { console.log('hier bin ich!!!', drinkPic.value); - if (drinkPic.value && drinkPic.value instanceof File) + drink.loading = true; + if (drinkPic.value && drinkPic.value instanceof File) { store .upload_drink_picture(drink, drinkPic.value) - .then(() => { - root?.$forceUpdate(); - }) .catch((response: Response) => { if (response && response.status == 400) { onPictureRejected(); } + }) + .finally(() => { + drink.loading = false; }); + } + } + + function deletePicture(drink: Row) { + drink.loading = true; + void store.delete_drink_picture(drink).finally(() => { + drink.loading = false; + }); } return { @@ -475,6 +497,7 @@ export default defineComponent({ showNewDrink, drinkPic, savePicture, + deletePicture, console, }; }, diff --git a/src/plugins/pricelist/components/DrinkTypes.vue b/src/plugins/pricelist/components/DrinkTypes.vue index 348cc74..3071aae 100644 --- a/src/plugins/pricelist/components/DrinkTypes.vue +++ b/src/plugins/pricelist/components/DrinkTypes.vue @@ -70,14 +70,14 @@ export default defineComponent({ label: 'Getränkeart', field: 'name', align: 'left', - sortable: true + sortable: true, }, { name: 'actions', label: 'Aktionen', field: 'actions', - align: 'right' - } + align: 'right', + }, ]; async function addType() { @@ -94,7 +94,7 @@ export default defineComponent({ try { await store.changeDrinkTypeName({ id: actualDrinkType.value.id, - name: newDrinkTypeName.value + name: newDrinkTypeName.value, }); } catch (e) {} discardChanges(); @@ -121,9 +121,9 @@ export default defineComponent({ actualDrinkType, newDrinkTypeName, discardChanges, - saveChanges + saveChanges, }; - } + }, }); diff --git a/src/plugins/pricelist/store.ts b/src/plugins/pricelist/store.ts index 0177ef2..1018e98 100644 --- a/src/plugins/pricelist/store.ts +++ b/src/plugins/pricelist/store.ts @@ -15,6 +15,7 @@ interface Drink extends Omit, 'volumes'> volumes: DrinkPriceVolume[]; cost_price_pro_volume: WritableComputedRef; _cost_price_pro_volume?: number; + loading: boolean; } class DrinkPriceVolume implements DrinkPriceVolume { @@ -80,6 +81,7 @@ class Drink { this.tags = tags; this.type = type; this.volumes = []; + this.loading = false; } } @@ -309,6 +311,9 @@ export const usePricelistStore = defineStore({ }, }); }, + async delete_drink_picture(drink: Drink) { + await api.delete(`pricelist/drinks/${drink.id}/picture`); + }, }, }); From 3d20292898e712e03e65b6e78765cadd28245397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 28 Mar 2021 11:34:36 +0200 Subject: [PATCH 02/51] [pricelist][picture] update picture if changed, add no-image.svg --- public/no-image.svg | 168 ++++++++++++++++++ src/flaschengeist.d.ts | 1 + .../pricelist/components/CalculationTable.vue | 27 ++- .../components/CalculationTable/NewDrink.vue | 1 + src/plugins/pricelist/store.ts | 9 +- 5 files changed, 188 insertions(+), 18 deletions(-) create mode 100644 public/no-image.svg diff --git a/public/no-image.svg b/public/no-image.svg new file mode 100644 index 0000000..097233d --- /dev/null +++ b/public/no-image.svg @@ -0,0 +1,168 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + Kein Bild vorhanden + + diff --git a/src/flaschengeist.d.ts b/src/flaschengeist.d.ts index a081c23..8956465 100644 --- a/src/flaschengeist.d.ts +++ b/src/flaschengeist.d.ts @@ -82,6 +82,7 @@ declare namespace FG { tags?: Array; type?: DrinkType; volumes: Array; + uuid: string; } interface DrinkIngredient { id: number; diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index 5e26945..7c59483 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -60,10 +60,17 @@ /> + + :src="drinks_props.row.uuid ? `/api/pricelist/picture/${drinks_props.row.uuid}?size=256`: 'no-image.svg'" + placeholder-src='no-image.svg' + > + +