release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
3 changed files with 54 additions and 26 deletions
Showing only changes of commit d42c6dcce1 - Show all commits

View File

@ -59,23 +59,34 @@
@click="deleteDrink(drinks_props.row)" @click="deleteDrink(drinks_props.row)"
/> />
</q-td> </q-td>
<q-td key="picture" :props="drinks_props" style="width: 128px"> <q-td key="picture" :props="drinks_props" style="min-width: 256px">
<q-img <q-img
:src="`http://localhost/api/pricelist/drinks/${drinks_props.row.id}/picture?size=128`" v-if="!drinks_props.row.loading"
:src="`http://localhost/api/pricelist/drinks/${drinks_props.row.id}/picture?size=256`"
/> />
<q-popup-edit <q-popup-edit v-model="drinkPic" @update:modelValue="savePicture(drinks_props.row)">
v-slot="scope" <template #default="scope">
v-model="drinkPic" <div class="full-width row">
buttons <q-file v-model="scope.value" filled>
label-set="Speichern" <template #prepend>
label-cancel="Abbrechen" <q-icon name="attach_file" />
@update:modelValue="savePicture(drinks_props.row)" </template>
> </q-file>
<q-file v-model="scope.value" filled> <div class="full-width row justify-between">
<template #prepend> <q-btn label="Abbrechen" flat color="primary" @click="scope.cancel" />
<q-icon name="attach_file" /> <q-btn
</template> label="Löschen"
</q-file> flat
color="primary"
@click="
scope.cancel();
deletePicture(drinks_props.row);
"
/>
<q-btn label="Speichern" flat color="primary" @click="scope.set" />
</div>
</div>
</template>
</q-popup-edit> </q-popup-edit>
</q-td> </q-td>
<q-td key="name" :props="drinks_props"> <q-td key="name" :props="drinks_props">
@ -446,20 +457,31 @@ export default defineComponent({
}); });
drinkPic.value = undefined; drinkPic.value = undefined;
} }
interface Row extends Drink {
expand: boolean;
}
function savePicture(drink: Drink) { function savePicture(drink: Drink) {
console.log('hier bin ich!!!', drinkPic.value); 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 store
.upload_drink_picture(drink, drinkPic.value) .upload_drink_picture(drink, drinkPic.value)
.then(() => {
root?.$forceUpdate();
})
.catch((response: Response) => { .catch((response: Response) => {
if (response && response.status == 400) { if (response && response.status == 400) {
onPictureRejected(); onPictureRejected();
} }
})
.finally(() => {
drink.loading = false;
}); });
}
}
function deletePicture(drink: Row) {
drink.loading = true;
void store.delete_drink_picture(drink).finally(() => {
drink.loading = false;
});
} }
return { return {
@ -475,6 +497,7 @@ export default defineComponent({
showNewDrink, showNewDrink,
drinkPic, drinkPic,
savePicture, savePicture,
deletePicture,
console, console,
}; };
}, },

View File

@ -70,14 +70,14 @@ export default defineComponent({
label: 'Getränkeart', label: 'Getränkeart',
field: 'name', field: 'name',
align: 'left', align: 'left',
sortable: true sortable: true,
}, },
{ {
name: 'actions', name: 'actions',
label: 'Aktionen', label: 'Aktionen',
field: 'actions', field: 'actions',
align: 'right' align: 'right',
} },
]; ];
async function addType() { async function addType() {
@ -94,7 +94,7 @@ export default defineComponent({
try { try {
await store.changeDrinkTypeName({ await store.changeDrinkTypeName({
id: actualDrinkType.value.id, id: actualDrinkType.value.id,
name: newDrinkTypeName.value name: newDrinkTypeName.value,
}); });
} catch (e) {} } catch (e) {}
discardChanges(); discardChanges();
@ -121,9 +121,9 @@ export default defineComponent({
actualDrinkType, actualDrinkType,
newDrinkTypeName, newDrinkTypeName,
discardChanges, discardChanges,
saveChanges saveChanges,
}; };
} },
}); });
</script> </script>

View File

@ -15,6 +15,7 @@ interface Drink extends Omit<Omit<FG.Drink, 'cost_price_pro_volume'>, 'volumes'>
volumes: DrinkPriceVolume[]; volumes: DrinkPriceVolume[];
cost_price_pro_volume: WritableComputedRef<number | undefined>; cost_price_pro_volume: WritableComputedRef<number | undefined>;
_cost_price_pro_volume?: number; _cost_price_pro_volume?: number;
loading: boolean;
} }
class DrinkPriceVolume implements DrinkPriceVolume { class DrinkPriceVolume implements DrinkPriceVolume {
@ -80,6 +81,7 @@ class Drink {
this.tags = tags; this.tags = tags;
this.type = type; this.type = type;
this.volumes = []; 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`);
},
}, },
}); });