2021-04-18 20:33:32 +00:00
|
|
|
<template>
|
2021-05-27 10:53:18 +00:00
|
|
|
<q-expansion-item
|
|
|
|
v-if="isGranted(entry)"
|
|
|
|
clickable
|
|
|
|
:label="getTitle(entry)"
|
|
|
|
:icon="entry.icon"
|
|
|
|
expand-separator
|
|
|
|
>
|
2021-05-20 18:31:37 +00:00
|
|
|
<q-list class="q-ml-lg">
|
|
|
|
<div v-for="child in entry.children" :key="child.link">
|
|
|
|
<q-item v-if="isGranted(child)" clickable :to="{ name: child.link }">
|
|
|
|
<q-menu context-menu>
|
|
|
|
<q-btn v-close-popup label="Verknüpfung erstellen" dense @click="addShortCut(child)" />
|
|
|
|
</q-menu>
|
|
|
|
<q-item-section avatar>
|
|
|
|
<q-icon :name="child.icon" />
|
|
|
|
</q-item-section>
|
|
|
|
<q-item-section>
|
|
|
|
<q-item-label>
|
2021-05-25 19:54:49 +00:00
|
|
|
{{ getTitle(child) }}
|
2021-05-20 18:31:37 +00:00
|
|
|
</q-item-label>
|
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</div>
|
|
|
|
</q-list>
|
2021-04-18 20:33:32 +00:00
|
|
|
</q-expansion-item>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-11-16 13:23:18 +00:00
|
|
|
import { defineComponent, PropType } from 'vue';
|
2021-05-27 10:35:25 +00:00
|
|
|
import { hasPermissions } from '@flaschengeist/api';
|
2021-05-25 14:13:15 +00:00
|
|
|
import { FG_Plugin } from '@flaschengeist/types';
|
2021-04-18 20:33:32 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'EssentialExpansionLink',
|
2021-05-20 18:31:37 +00:00
|
|
|
components: {},
|
2021-04-18 20:33:32 +00:00
|
|
|
props: {
|
|
|
|
entry: {
|
|
|
|
type: Object as PropType<FG_Plugin.MenuLink>,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2021-04-18 21:26:54 +00:00
|
|
|
emits: {
|
|
|
|
addShortCut: (val: FG_Plugin.MenuLink) => val.link,
|
|
|
|
},
|
2021-11-16 13:23:18 +00:00
|
|
|
setup(_, { emit }) {
|
2021-05-20 18:31:37 +00:00
|
|
|
function isGranted(val: FG_Plugin.MenuLink) {
|
2021-11-16 13:23:18 +00:00
|
|
|
return hasPermissions(val.permissions || []);
|
2021-05-25 19:54:49 +00:00
|
|
|
}
|
|
|
|
function getTitle(entry: FG_Plugin.MenuLink) {
|
2021-11-16 13:23:18 +00:00
|
|
|
return typeof entry.title === 'function' ? entry.title() : entry.title;
|
2021-05-20 18:31:37 +00:00
|
|
|
}
|
2021-05-25 19:54:49 +00:00
|
|
|
|
2021-04-18 21:26:54 +00:00
|
|
|
function addShortCut(val: FG_Plugin.MenuLink) {
|
2021-05-20 18:31:37 +00:00
|
|
|
emit('addShortCut', val);
|
2021-04-18 21:26:54 +00:00
|
|
|
}
|
|
|
|
|
2021-05-25 19:54:49 +00:00
|
|
|
return { isGranted, getTitle, addShortCut };
|
2021-04-18 20:33:32 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|