flaschengeist-frontend/src/components/navigation/ShortCutLink.vue

41 lines
968 B
Vue
Raw Normal View History

<template>
<q-btn flat dense :icon="icon" :to="{ name: link }" v-if="hasPermissions" />
</template>
<script lang="ts">
import { computed, defineComponent } from '@vue/composition-api';
import { Store } from 'vuex';
import { StateInterface } from 'src/store';
export default defineComponent({
name: 'ShortCutLink',
props: {
link: {
required: true,
type: String
},
icon: {
required: true,
type: String
2020-10-31 18:33:05 +00:00
},
permissions: {
default: undefined
}
2020-10-31 18:33:05 +00:00
},
setup(props, { root }) {
2020-10-31 18:33:05 +00:00
const hasPermissions = computed(() => {
let permissions = props.permissions;
2020-10-31 18:33:05 +00:00
if (permissions) {
return (<string[]>permissions).every(permission => {
return (<{ 'user/permissions': string[] }>(
(<Store<StateInterface>>root.$store).getters
))['user/permissions'].includes(permission);
});
2020-10-31 18:33:05 +00:00
}
return true;
});
return { hasPermissions };
}
});
</script>