[view][fix] enable, disable pic; fix reload drinks after update or delete

This commit is contained in:
Tim Gröger 2021-11-15 10:13:35 +01:00
parent f9cfd668bb
commit 8401acd293
1 changed files with 22 additions and 3 deletions

View File

@ -18,6 +18,7 @@
<div class="row justify-end q-gutter-sm"> <div class="row justify-end q-gutter-sm">
<search-input v-model="search" :keys="search_keys" /> <search-input v-model="search" :keys="search_keys" />
<slot></slot> <slot></slot>
<q-toggle v-model="showPic" icon="mdi-camera-burst" />
<q-btn v-if="!public && !nodetails" label="Aufpreise"> <q-btn v-if="!public && !nodetails" label="Aufpreise">
<q-menu anchor="center middle" self="center middle"> <q-menu anchor="center middle" self="center middle">
<min-price-setting /> <min-price-setting />
@ -37,7 +38,7 @@
<template #item="props"> <template #item="props">
<div class="q-pa-xs col-xs-12 col-sm-6 col-md-4"> <div class="q-pa-xs col-xs-12 col-sm-6 col-md-4">
<q-card> <q-card>
<q-img style="max-height: 256px" :src="image(props.row.uuid)"> <q-img v-if="showPic" style="max-height: 256px" :src="image(props.row.uuid)">
<div <div
v-if="!public && !nodetails && editable" v-if="!public && !nodetails && editable"
class="absolute-top-right justify-end" class="absolute-top-right justify-end"
@ -82,6 +83,19 @@
</div> </div>
</template> </template>
</q-img> </q-img>
<q-card-section v-if="!showPic">
<div class="row">
<div class="col">
<div class="text-h4 text-center">
{{ props.row.name }}
</div>
<div class="text-caption text-center">
{{ props.row.type.name }}
</div>
</div>
<q-btn rounded icon="mdi-pencil" @click="editDrink = props.row" />
</div>
</q-card-section>
<q-card-section> <q-card-section>
<q-badge <q-badge
v-for="tag in props.row.tags" v-for="tag in props.row.tags"
@ -425,11 +439,12 @@ export default defineComponent({
void store.updateDrink(drink); void store.updateDrink(drink);
} }
function deleteDrink() { async function deleteDrink() {
if (editDrink.value) { if (editDrink.value) {
store.deleteDrink(editDrink.value); await store.deleteDrink(editDrink.value);
} }
editDrink.value = undefined; editDrink.value = undefined;
onRequest({ pagination: pagination.value, filter: search.value });
} }
const showNewDrink = ref(false); const showNewDrink = ref(false);
@ -522,6 +537,7 @@ export default defineComponent({
} }
editDrink.value = undefined; editDrink.value = undefined;
notLoading.value = true; notLoading.value = true;
onRequest({ pagination: pagination.value, filter: search.value });
} }
function get_volumes(drink_id: number) { function get_volumes(drink_id: number) {
@ -546,6 +562,8 @@ export default defineComponent({
return 'no-image.svg'; return 'no-image.svg';
} }
const showPic = ref(true);
return { return {
drinks: computed(() => store.drinks), drinks: computed(() => store.drinks),
pagination, pagination,
@ -574,6 +592,7 @@ export default defineComponent({
image, image,
loading, loading,
onRequest, onRequest,
showPic,
}; };
}, },
}); });