2020-10-02 07:13:14 +00:00
|
|
|
<template>
|
2021-02-01 23:48:33 +00:00
|
|
|
<q-item v-if="isGranted" clickable tag="a" target="self" :to="{ name: link }">
|
2020-10-17 10:56:25 +00:00
|
|
|
<q-item-section v-if="icon" avatar>
|
2020-10-31 20:30:02 +00:00
|
|
|
<q-icon :name="icon" />
|
2020-10-02 07:13:14 +00:00
|
|
|
</q-item-section>
|
|
|
|
|
|
|
|
<q-item-section>
|
2020-10-17 10:56:25 +00:00
|
|
|
<q-item-label>{{ realTitle }}</q-item-label>
|
2020-10-31 20:30:02 +00:00
|
|
|
<!--<q-item-label caption>
|
|
|
|
{{ caption }}
|
|
|
|
</q-item-label>-->
|
2020-10-02 07:13:14 +00:00
|
|
|
</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 05:19:43 +00:00
|
|
|
import { useStore } from 'vuex';
|
2021-01-30 03:16:17 +00:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2020-11-24 17:42:43 +00:00
|
|
|
import { hasPermissions } from 'src/utils/permission';
|
2020-10-02 07:13:14 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'EssentialLink',
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
2021-03-18 16:23:57 +00:00
|
|
|
required: true,
|
2020-10-02 07:13:14 +00:00
|
|
|
},
|
|
|
|
caption: {
|
|
|
|
type: String,
|
2021-03-18 16:23:57 +00:00
|
|
|
default: '',
|
2020-10-02 07:13:14 +00:00
|
|
|
},
|
|
|
|
link: {
|
|
|
|
type: String,
|
2021-01-30 07:38:44 +00:00
|
|
|
default: 'dashboard',
|
2020-10-02 07:13:14 +00:00
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
2021-03-18 16:23:57 +00:00
|
|
|
default: '',
|
2020-10-31 18:33:05 +00:00
|
|
|
},
|
|
|
|
permissions: {
|
2021-01-31 21:21:49 +00:00
|
|
|
default: () => Array<string>(),
|
|
|
|
type: Array as () => Array<string>,
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2020-10-09 16:04:32 +00:00
|
|
|
},
|
2020-10-17 10:56:25 +00:00
|
|
|
|
2021-01-30 05:19:43 +00:00
|
|
|
setup(props) {
|
2020-10-28 23:12:46 +00:00
|
|
|
let title = computed<string>(() => {
|
|
|
|
if (props.title.includes('loadFromStore')) {
|
2021-01-30 05:19:43 +00:00
|
|
|
const store = useStore();
|
|
|
|
|
2020-10-28 23:12:46 +00:00
|
|
|
const startIndex = props.title.indexOf('(') + 1;
|
|
|
|
const endIndex = props.title.indexOf(')');
|
2021-01-27 07:16:44 +00:00
|
|
|
const substring = props.title.substring(startIndex, endIndex).replace(/"/g, '');
|
2020-10-29 00:39:06 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
2021-01-30 05:19:43 +00:00
|
|
|
return <string>store.getters[substring];
|
2020-10-28 23:12:46 +00:00
|
|
|
}
|
|
|
|
return props.title;
|
|
|
|
});
|
2020-10-31 18:33:05 +00:00
|
|
|
|
2021-01-31 21:21:49 +00:00
|
|
|
const isGranted = computed(() => hasPermissions(props.permissions));
|
2020-10-31 18:33:05 +00:00
|
|
|
|
2020-11-06 00:28:35 +00:00
|
|
|
return { realTitle: title, isGranted };
|
2021-03-18 16:23:57 +00:00
|
|
|
},
|
2020-10-02 07:13:14 +00:00
|
|
|
});
|
|
|
|
</script>
|