[core] Fixed menu link title generation

This commit is contained in:
Ferdinand Thiessen 2021-05-25 21:54:49 +02:00
parent 0c279289b2
commit d422380adc
2 changed files with 412 additions and 401 deletions

View File

@ -2,9 +2,7 @@
<q-expansion-item <q-expansion-item
v-if="isGranted(entry)" v-if="isGranted(entry)"
clickable clickable
tag="a" :label="getTitle(entry)"
target="self"
:label="title"
:icon="entry.icon" :icon="entry.icon"
expand-separator expand-separator
> >
@ -19,7 +17,7 @@
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<q-item-label> <q-item-label>
{{ child.title }} {{ getTitle(child) }}
</q-item-label> </q-item-label>
</q-item-section> </q-item-section>
</q-item> </q-item>
@ -29,9 +27,9 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, PropType } from 'vue'; import { defineComponent, PropType } from 'vue';
import { hasPermissions } from '@flaschengeist/api';
import { FG_Plugin } from '@flaschengeist/types'; import { FG_Plugin } from '@flaschengeist/types';
import { useMainStore } from 'app/api';
export default defineComponent({ export default defineComponent({
name: 'EssentialExpansionLink', name: 'EssentialExpansionLink',
@ -46,17 +44,20 @@ export default defineComponent({
addShortCut: (val: FG_Plugin.MenuLink) => val.link, addShortCut: (val: FG_Plugin.MenuLink) => val.link,
}, },
setup(props, { emit }) { setup(props, { emit }) {
const store = useMainStore();
function isGranted(val: FG_Plugin.MenuLink) { function isGranted(val: FG_Plugin.MenuLink) {
return hasPermissions(val.permissions || []); return !val.permissions || val.permissions.every((p) => store.permissions.includes(p));
} }
const title = computed(() => function getTitle(entry: FG_Plugin.MenuLink) {
typeof props.entry.title === 'function' ? props.entry.title() : props.entry.title return typeof entry.title === 'function' ? entry.title() : entry.title;
); }
function addShortCut(val: FG_Plugin.MenuLink) { function addShortCut(val: FG_Plugin.MenuLink) {
emit('addShortCut', val); emit('addShortCut', val);
} }
return { isGranted, title, addShortCut }; return { isGranted, getTitle, addShortCut };
}, },
}); });
</script> </script>

790
yarn.lock

File diff suppressed because it is too large Load Diff