diff --git a/src/plugins/pricelist/components/CalculationTable.vue b/src/plugins/pricelist/components/CalculationTable.vue index 20cd3e7..e5415a1 100644 --- a/src/plugins/pricelist/components/CalculationTable.vue +++ b/src/plugins/pricelist/components/CalculationTable.vue @@ -19,7 +19,7 @@ >, - default: undefined + default: undefined, }, editable: { type: Boolean, diff --git a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue index 776d3ca..2ba74c7 100644 --- a/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue +++ b/src/plugins/pricelist/components/CalculationTable/DrinkPriceVolumes.vue @@ -26,7 +26,10 @@ step="0.001" @update:model-value="updateVolume(volume)" /> -
+
Abgabe entfernen @@ -41,7 +44,12 @@
-
{{ price.price.toFixed(2) }}€
+
+ {{ price.price.toFixed(2) }}€ +
-
+
{{ price.description }}
-
+
Preis entfernen @@ -90,7 +101,10 @@ > Einer der Preise ist unterhalb des niedrigsten minimal Preises.
-
+
Preis hinzufügen @@ -103,7 +117,7 @@ @@ -128,6 +142,9 @@ import { DrinkPriceVolume } from 'src/plugins/pricelist/store'; import Ingredients from 'src/plugins/pricelist/components/CalculationTable/Ingredients.vue'; import NewPrice from 'src/plugins/pricelist/components/CalculationTable/NewPrice.vue'; import { calc_volume, clone } from '../../utils/utils'; +import { hasPermission } from 'src/utils/permission'; +import { PERMISSIONS } from '../../permissions'; + export default defineComponent({ name: 'DrinkPriceVolume', components: { Ingredients, NewPrice }, @@ -138,7 +155,7 @@ export default defineComponent({ }, costPerVolume: { type: undefined, - default: undefined + default: undefined, }, editable: { type: Boolean, @@ -308,6 +325,8 @@ export default defineComponent({ deleteIngredient, change, isUnderMinPrice, + hasPermission, + PERMISSIONS, }; }, }); diff --git a/src/plugins/pricelist/components/DrinkModify.vue b/src/plugins/pricelist/components/DrinkModify.vue index 661bf41..c2b0969 100644 --- a/src/plugins/pricelist/components/DrinkModify.vue +++ b/src/plugins/pricelist/components/DrinkModify.vue @@ -126,7 +126,7 @@ ; } const store = usePricelistStore(); onBeforeMount(() => { @@ -90,13 +92,36 @@ export default defineComponent({ }, }); - const tabs: Tab[] = [ - { name: 'pricelist', label: 'Getränke' }, - { name: 'extra_ingredients', label: 'Zutaten' }, - { name: 'drink_types', label: 'Getränketypen' }, - { name: 'tags', label: 'Tags' }, + const _tabs: Tab[] = [ + { name: 'pricelist', label: 'Getränke', permissions: ['drink_edit'] }, + { name: 'extra_ingredients', label: 'Zutaten', permissions: [] }, + { + 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('pricelist'); return { tabs, tab, showDrawer }; diff --git a/src/plugins/pricelist/permissions.ts b/src/plugins/pricelist/permissions.ts new file mode 100644 index 0000000..a378a74 --- /dev/null +++ b/src/plugins/pricelist/permissions.ts @@ -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', +}; diff --git a/src/plugins/pricelist/routes/index.ts b/src/plugins/pricelist/routes/index.ts index 8242505..fd28920 100644 --- a/src/plugins/pricelist/routes/index.ts +++ b/src/plugins/pricelist/routes/index.ts @@ -48,7 +48,7 @@ export const innerRoutes: FG_Plugin.MenuRoute[] = [ title: 'Einstellungen', icon: 'mdi-coffee-to-go', shortcut: false, - permissions: ['user'], + permissions: ['drink_edit', 'drink_tag_edit'], route: { path: 'settings', name: 'drinks-settings',