salix-front/src/components/PinnedModules.vue

92 lines
2.6 KiB
Vue
Raw Normal View History

2022-11-29 13:45:48 +00:00
<script setup>
import { onMounted, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useNavigationStore } from 'src/stores/useNavigationStore';
2023-08-08 10:11:27 +00:00
import { getUrl } from 'src/composables/getUrl';
import { useRoute } from 'vue-router';
2022-11-29 13:45:48 +00:00
const navigation = useNavigationStore();
const { t } = useI18n();
2023-08-08 10:11:27 +00:00
const route = useRoute();
2022-11-29 13:45:48 +00:00
onMounted(() => {
navigation.fetchPinned();
});
2023-08-08 10:11:27 +00:00
defineExpose({
redirect,
});
2022-11-29 13:45:48 +00:00
const pinnedModules = computed(() => navigation.getPinnedModules());
2023-08-08 10:11:27 +00:00
async function redirect() {
let section = route.path.substring(1);
if (!route.path.includes('/')) return (window.location.href = await getUrl(section));
section = section.substring(0, section.indexOf('/'));
2023-08-09 08:02:48 +00:00
if (route?.params?.id)
return (window.location.href = await getUrl(
`${section}/${route.params.id}/summary`
));
return (window.location.href = await getUrl(section + 'dashboard'));
2023-08-08 10:11:27 +00:00
}
2022-11-29 13:45:48 +00:00
</script>
<template>
2023-08-08 10:11:27 +00:00
<QMenu anchor="bottom left" max-width="300px" max-height="400px">
2023-08-09 08:02:48 +00:00
<div v-if="pinnedModules.length >= 0" class="row justify-around q-pa-md">
2023-08-08 10:11:27 +00:00
<QBtn
flat
stack
size="lg"
icon="more_up"
class="col-5"
@click="redirect($route.params.id)"
2023-04-11 11:31:03 +00:00
>
2023-08-08 10:11:27 +00:00
<div class="text-center button-text">Salix</div>
</QBtn>
<QBtn flat stack size="lg" icon="home" class="col-5" to="/">
<div class="text-center button-text">{{ t('Home') }}</div>
</QBtn>
<div class="row col-12 justify-around q-mt-md">
2023-04-11 11:31:03 +00:00
<QBtn
flat
stack
size="lg"
:icon="item.icon"
color="primary"
2023-08-08 10:11:27 +00:00
class="col-5"
:to="{ name: item.name }"
2023-08-08 10:11:27 +00:00
v-for="item of pinnedModules"
:key="item.title"
>
<div class="text-center text-primary button-text">
{{ t(item.title) }}
</div>
2023-04-11 11:31:03 +00:00
</QBtn>
</div>
2023-08-08 10:11:27 +00:00
</div>
<div v-else>
2023-04-11 11:31:03 +00:00
<div
class="row no-wrap q-pa-xs flex-item text-center text-grey-5"
style="min-width: 200px"
>
{{ t('globals.noPinnedModules') }}
</div>
2023-08-08 10:11:27 +00:00
</div>
2023-04-11 11:31:03 +00:00
</QMenu>
2022-11-29 13:45:48 +00:00
</template>
<style lang="scss" scoped>
.button-text {
font-size: 10px;
margin-top: 5px;
}
</style>
2023-08-08 10:11:27 +00:00
<i18n>
en:
Home: Home
es:
Home: Inicio
</i18n>