release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
7 changed files with 103 additions and 18 deletions
Showing only changes of commit 8b21ccf978 - Show all commits

View File

@ -19,7 +19,7 @@
</q-menu> </q-menu>
</q-btn> </q-btn>
<q-btn <q-btn
v-if="!public && !nodetails && editable" v-if="!public && !nodetails && editable && hasPermission(PERMISSIONS.CREATE)"
color="primary" color="primary"
round round
icon="mdi-plus" icon="mdi-plus"
@ -155,6 +155,8 @@ import { filter, Search } from '../utils/filter';
import { Notify } from 'quasar'; import { Notify } from 'quasar';
import { sort } from '../utils/sort'; import { sort } from '../utils/sort';
import { DeleteObjects } from 'src/plugins/pricelist/utils/utils'; import { DeleteObjects } from 'src/plugins/pricelist/utils/utils';
import { hasPermission } from 'src/utils/permission';
import { PERMISSIONS } from 'src/plugins/pricelist/permissions';
export default defineComponent({ export default defineComponent({
name: 'CalculationTable', name: 'CalculationTable',
@ -185,7 +187,6 @@ export default defineComponent({
void store.getDrinks(); void store.getDrinks();
}); });
const columns = [ const columns = [
{ {
name: 'picture', name: 'picture',
@ -498,6 +499,8 @@ export default defineComponent({
notLoading, notLoading,
getImageLoading, getImageLoading,
newDrink, newDrink,
hasPermission,
PERMISSIONS,
}; };
}, },
}); });

View File

@ -32,7 +32,7 @@ export default defineComponent({
props: { props: {
steps: { steps: {
type: Array as PropType<Array<string>>, type: Array as PropType<Array<string>>,
default: undefined default: undefined,
}, },
editable: { editable: {
type: Boolean, type: Boolean,

View File

@ -26,7 +26,10 @@
step="0.001" step="0.001"
@update:model-value="updateVolume(volume)" @update:model-value="updateVolume(volume)"
/> />
<div v-if="deleteable && editable" class="q-pa-sm col-2 text-right"> <div
v-if="deleteable && editable && hasPermission(PERMISSIONS.DELETE_VOLUME)"
class="q-pa-sm col-2 text-right"
>
<q-btn round icon="mdi-delete" size="sm" color="negative" @click="deleteVolume"> <q-btn round icon="mdi-delete" size="sm" color="negative" @click="deleteVolume">
<q-tooltip> Abgabe entfernen </q-tooltip> <q-tooltip> Abgabe entfernen </q-tooltip>
</q-btn> </q-btn>
@ -41,7 +44,12 @@
<div class="q-pa-sm"> <div class="q-pa-sm">
<div v-for="(price, index) in volume.prices" :key="price.id"> <div v-for="(price, index) in volume.prices" :key="price.id">
<div class="fit row justify-around q-py-sm"> <div class="fit row justify-around q-py-sm">
<div v-if="!editable" class="text-body1 col-3">{{ price.price.toFixed(2) }}</div> <div
v-if="!editable || !hasPermission(PERMISSIONS.EDIT_PRICE)"
class="text-body1 col-3"
>
{{ price.price.toFixed(2) }}
</div>
<q-input <q-input
v-else v-else
v-model.number="price.price" v-model.number="price.price"
@ -58,13 +66,16 @@
<div class="text-body1 col-2"> <div class="text-body1 col-2">
<q-toggle <q-toggle
v-model="price.public" v-model="price.public"
:disable="!editable" :disable="!editable || !hasPermission(PERMISSIONS.EDIT_PRICE)"
checked-icon="mdi-earth" checked-icon="mdi-earth"
unchecked-icon="mdi-earth-off" unchecked-icon="mdi-earth-off"
@update:model-value="change" @update:model-value="change"
/> />
</div> </div>
<div v-if="!editable" class="text-body1 col-5"> <div
v-if="!editable || !hasPermission(PERMISSIONS.EDIT_PRICE)"
class="text-body1 col-5"
>
{{ price.description }} {{ price.description }}
</div> </div>
<q-input <q-input
@ -76,7 +87,7 @@
label="Beschreibung" label="Beschreibung"
@update:model-value="change" @update:model-value="change"
/> />
<div v-if="editable" class="col-1"> <div v-if="editable && hasPermission(PERMISSIONS.DELETE_PRICE)" class="col-1">
<q-btn round icon="mdi-delete" color="negative" size="xs" @click="deletePrice(price)"> <q-btn round icon="mdi-delete" color="negative" size="xs" @click="deletePrice(price)">
<q-tooltip> Preis entfernen </q-tooltip> <q-tooltip> Preis entfernen </q-tooltip>
</q-btn> </q-btn>
@ -90,7 +101,10 @@
> >
Einer der Preise ist unterhalb des niedrigsten minimal Preises. Einer der Preise ist unterhalb des niedrigsten minimal Preises.
</div> </div>
<div v-if="editable" class="full-width row justify-end text-right"> <div
v-if="editable && hasPermission(PERMISSIONS.EDIT_PRICE)"
class="full-width row justify-end text-right"
>
<q-btn round icon="mdi-plus" size="sm" color="primary"> <q-btn round icon="mdi-plus" size="sm" color="primary">
<q-tooltip> Preis hinzufügen </q-tooltip> <q-tooltip> Preis hinzufügen </q-tooltip>
<q-menu anchor="center middle" self="center middle"> <q-menu anchor="center middle" self="center middle">
@ -103,7 +117,7 @@
<ingredients <ingredients
v-if="!public && !costPerVolume" v-if="!public && !costPerVolume"
v-model="volume.ingredients" v-model="volume.ingredients"
:editable="editable" :editable="editable && hasPermission(PERMISSIONS.EDIT_INGREDIENTS_DRINK)"
@update="updateVolume(volume)" @update="updateVolume(volume)"
@delete-ingredient="deleteIngredient" @delete-ingredient="deleteIngredient"
/> />
@ -128,6 +142,9 @@ import { DrinkPriceVolume } from 'src/plugins/pricelist/store';
import Ingredients from 'src/plugins/pricelist/components/CalculationTable/Ingredients.vue'; import Ingredients from 'src/plugins/pricelist/components/CalculationTable/Ingredients.vue';
import NewPrice from 'src/plugins/pricelist/components/CalculationTable/NewPrice.vue'; import NewPrice from 'src/plugins/pricelist/components/CalculationTable/NewPrice.vue';
import { calc_volume, clone } from '../../utils/utils'; import { calc_volume, clone } from '../../utils/utils';
import { hasPermission } from 'src/utils/permission';
import { PERMISSIONS } from '../../permissions';
export default defineComponent({ export default defineComponent({
name: 'DrinkPriceVolume', name: 'DrinkPriceVolume',
components: { Ingredients, NewPrice }, components: { Ingredients, NewPrice },
@ -138,7 +155,7 @@ export default defineComponent({
}, },
costPerVolume: { costPerVolume: {
type: undefined, type: undefined,
default: undefined default: undefined,
}, },
editable: { editable: {
type: Boolean, type: Boolean,
@ -308,6 +325,8 @@ export default defineComponent({
deleteIngredient, deleteIngredient,
change, change,
isUnderMinPrice, isUnderMinPrice,
hasPermission,
PERMISSIONS,
}; };
}, },
}); });

View File

@ -126,7 +126,7 @@
<drink-price-volumes <drink-price-volumes
v-model="edit_volumes" v-model="edit_volumes"
:cost-per-volume="cost_per_volume" :cost-per-volume="cost_per_volume"
editable :editable="hasPermission(PERMISSIONS.EDIT_VOLUME)"
@update="updateVolume" @update="updateVolume"
@delete-volume="deleteVolume" @delete-volume="deleteVolume"
@delete-price="deletePrice" @delete-price="deletePrice"
@ -150,6 +150,9 @@ import DrinkPriceVolumes from './CalculationTable/DrinkPriceVolumes.vue';
import { clone, calc_min_prices, DeleteObjects, calc_cost_per_volume } from '../utils/utils'; import { clone, calc_min_prices, DeleteObjects, calc_cost_per_volume } from '../utils/utils';
import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue'; import BuildManual from 'src/plugins/pricelist/components/CalculationTable/BuildManual.vue';
import config from 'src/config'; import config from 'src/config';
import { hasPermission } from 'src/utils/permission';
import { PERMISSIONS } from 'src/plugins/pricelist/permissions';
export default defineComponent({ export default defineComponent({
name: 'DrinkModify', name: 'DrinkModify',
components: { BuildManual, DrinkPriceVolumes }, components: { BuildManual, DrinkPriceVolumes },
@ -343,6 +346,8 @@ export default defineComponent({
edit_volumes, edit_volumes,
key, key,
hasIngredients, hasIngredients,
hasPermission,
PERMISSIONS,
}; };
}, },
}); });

View File

@ -56,6 +56,7 @@ import CalculationTable from 'src/plugins/pricelist/components/CalculationTable.
import ExtraIngredients from 'src/plugins/pricelist/components/ExtraIngredients.vue'; import ExtraIngredients from 'src/plugins/pricelist/components/ExtraIngredients.vue';
import Tags from '../components/Tags.vue'; import Tags from '../components/Tags.vue';
import { usePricelistStore } from 'src/plugins/pricelist/store'; import { usePricelistStore } from 'src/plugins/pricelist/store';
import { hasPermissions } from 'src/utils/permission';
export default defineComponent({ export default defineComponent({
name: 'Settings', name: 'Settings',
@ -64,6 +65,7 @@ export default defineComponent({
interface Tab { interface Tab {
name: string; name: string;
label: string; label: string;
permissions: Array<string>;
} }
const store = usePricelistStore(); const store = usePricelistStore();
onBeforeMount(() => { onBeforeMount(() => {
@ -90,13 +92,36 @@ export default defineComponent({
}, },
}); });
const tabs: Tab[] = [ const _tabs: Tab[] = [
{ name: 'pricelist', label: 'Getränke' }, { name: 'pricelist', label: 'Getränke', permissions: ['drink_edit'] },
{ name: 'extra_ingredients', label: 'Zutaten' }, { name: 'extra_ingredients', label: 'Zutaten', permissions: [] },
{ name: 'drink_types', label: 'Getränketypen' }, {
{ name: 'tags', label: 'Tags' }, name: 'drink_types',
label: 'Getränketypen',
permissions: ['drink_type_edit', 'drink_type_delete'],
},
{
name: 'tags',
label: 'Tags',
permissions: ['drink_tag_edit', 'drink_tag_create', 'drink_tag_delete'],
},
]; ];
const tabs = computed(() => {
const retVal: Tab[] = [];
_tabs.forEach((tab) => {
if (tab.permissions.length > 0) {
if (hasPermissions(tab.permissions)) {
retVal.push(tab);
}
}
if (tab.permissions.length === 0) {
retVal.push(tab);
}
});
return retVal;
});
const tab = ref<string>('pricelist'); const tab = ref<string>('pricelist');
return { tabs, tab, showDrawer }; return { tabs, tab, showDrawer };

View File

@ -0,0 +1,33 @@
export const PERMISSIONS = {
CREATE: 'drink_create',
EDIT: 'drink_edit',
DELETE: 'drink_delete',
CREATE_TAG: 'drink_tag_create',
EDIT_PRICE: 'edit_price',
DELETE_PRICE: 'delete_price',
EDIT_VOLUME: 'edit_volume',
DELETE_VOLUME: 'delete_volume',
EDIT_INGREDIENTS_DRINK: 'edit_ingredients_drink',
DELETE_INGREDIENTS_DRINK: 'delete_ingredients_drink',
EDIT_INGREDIENTS: 'edit_ingredients',
DELETE_INGREDIENTS: 'delete_ingredients',
EDIT_TAG: 'drink_tag_edit',
DELETE_TAG: 'drink_tag_delete',
CREATE_TYPE: 'drink_type_create',
EDIT_TYPE: 'drink_type_edit',
DELETE_TYPE: 'drink_type_delete',
EDIT_MIN_PRICES: 'edit_min_prices',
};

View File

@ -48,7 +48,7 @@ export const innerRoutes: FG_Plugin.MenuRoute[] = [
title: 'Einstellungen', title: 'Einstellungen',
icon: 'mdi-coffee-to-go', icon: 'mdi-coffee-to-go',
shortcut: false, shortcut: false,
permissions: ['user'], permissions: ['drink_edit', 'drink_tag_edit'],
route: { route: {
path: 'settings', path: 'settings',
name: 'drinks-settings', name: 'drinks-settings',