|
|
@@ -4,99 +4,105 @@ header principal (configuration, paramètres du compte...)
|
|
|
-->
|
|
|
|
|
|
<template>
|
|
|
- <v-menu offset-y left>
|
|
|
- <template #activator="{ on: { click }, attrs }">
|
|
|
- <v-tooltip bottom>
|
|
|
- <template #activator="{ on: on_tooltips , attrs: attrs_tooltips }">
|
|
|
- <v-btn
|
|
|
- icon
|
|
|
- v-bind="[attrs, attrs_tooltips]"
|
|
|
- color=""
|
|
|
- v-on="on_tooltips"
|
|
|
- @click="click"
|
|
|
- >
|
|
|
- <v-avatar
|
|
|
- v-if="menu.icon.avatarByDefault"
|
|
|
- size="30"
|
|
|
- >
|
|
|
- <UiImage :id="menu.icon.avatarId" :imageByDefault="menu.icon.avatarByDefault" :width="30"></UiImage>
|
|
|
- </v-avatar>
|
|
|
- <v-icon v-else class="ot-white--text" small>
|
|
|
- {{ menu.icon.name }}
|
|
|
- </v-icon>
|
|
|
- </v-btn>
|
|
|
- </template>
|
|
|
- <span>{{ $t(menu.title) }}</span>
|
|
|
- </v-tooltip>
|
|
|
- </template>
|
|
|
- <v-card scrollable>
|
|
|
- <v-card-title class="ot-header_menu text-body-2 font-weight-bold">
|
|
|
- {{$t(menu.title)}}
|
|
|
- </v-card-title>
|
|
|
- <v-card-text class="ma-0 pa-0 header-menu">
|
|
|
- <v-list dense :subheader="true">
|
|
|
- <template v-for="(item, index) in menu.children">
|
|
|
- <v-list-item
|
|
|
- :id="item.title"
|
|
|
- :key="index"
|
|
|
- :href="item.isExternalLink ? item.to : undefined"
|
|
|
- :to="!item.isExternalLink ? item.to : undefined"
|
|
|
- router
|
|
|
- exact
|
|
|
- >
|
|
|
- <v-list-item-title>
|
|
|
- <span v-if="item.icon">
|
|
|
- <v-avatar
|
|
|
- v-if="item.icon.avatarByDefault"
|
|
|
- size="30"
|
|
|
+ <v-tooltip
|
|
|
+ v-if="displayMenu"
|
|
|
+ :text="$t(menu.label)"
|
|
|
+ location="bottom"
|
|
|
+ >
|
|
|
+ <template #activator="{ props }">
|
|
|
+ <v-btn v-bind="props" icon width="48px">
|
|
|
+ <v-avatar v-if="menu.icon.avatarId || menu.icon.avatarByDefault" size="30">
|
|
|
+ <UiImage :id="menu.icon.avatarId" :defaultImage="menu.icon.avatarByDefault" :width="30"></UiImage>
|
|
|
+ </v-avatar>
|
|
|
+ <v-icon v-else class="text-ot-white" small>
|
|
|
+ {{ menu.icon.name }}
|
|
|
+ </v-icon>
|
|
|
+
|
|
|
+ <v-menu
|
|
|
+ :model-value="isOpened()"
|
|
|
+ activator="parent"
|
|
|
+ location="start"
|
|
|
+ @update:modelValue="onStateUpdated"
|
|
|
+ style="top: 48px;"
|
|
|
+ >
|
|
|
+ <v-card>
|
|
|
+ <v-card-title class="ot-header-menu text-body-2 font-weight-bold">
|
|
|
+ {{$t(menu.label)}}
|
|
|
+ </v-card-title>
|
|
|
+
|
|
|
+ <v-card-text class="ma-0 pa-0 header-menu">
|
|
|
+ <v-list density="compact" :subheader="true">
|
|
|
+ <template v-for="(child, index) in menu.children" :key="index">
|
|
|
+ <v-list-item
|
|
|
+
|
|
|
+ :id="child.label"
|
|
|
+ :href="!isInternalLink(child) ? child.to : undefined"
|
|
|
+ :to="isInternalLink(child) ? child.to : undefined"
|
|
|
>
|
|
|
- <UiImage :id="item.icon.avatarId" :imageByDefault="item.icon.avatarByDefault" :width="30"></UiImage>
|
|
|
- </v-avatar>
|
|
|
- <v-icon v-else class="ot-white--text" small>
|
|
|
- {{ item.icon.name }}
|
|
|
- </v-icon>
|
|
|
- </span>
|
|
|
- <span>{{$t(item.title)}}</span>
|
|
|
- </v-list-item-title>
|
|
|
- </v-list-item>
|
|
|
- </template>
|
|
|
- </v-list>
|
|
|
- </v-card-text>
|
|
|
- <v-card-actions class="ma-0 pa-0">
|
|
|
- <template v-for="(item, index) in menu.actions">
|
|
|
- <v-list-item
|
|
|
- :id="item.title"
|
|
|
- :key="index"
|
|
|
- :href="item.isExternalLink ? item.to : undefined"
|
|
|
- :to="!item.isExternalLink ? item.to : undefined"
|
|
|
- router
|
|
|
- >
|
|
|
- <v-list-item-title class="text-body-2 ot-white--text" v-text="$t(item.title)"/>
|
|
|
- </v-list-item>
|
|
|
- </template>
|
|
|
- </v-card-actions>
|
|
|
- </v-card>
|
|
|
+ <v-list-item-title>
|
|
|
+ <span v-if="child.icon">
|
|
|
+ <v-avatar v-if="menu.icon.avatarId || child.icon.avatarByDefault" size="30">
|
|
|
+ <UiImage :id="child.icon.avatarId" :defaultImage="child.icon.avatarByDefault" :width="30"></UiImage>
|
|
|
+ </v-avatar>
|
|
|
+ <v-icon v-else class="text-ot-white" small>
|
|
|
+ {{ child.icon.name }}
|
|
|
+ </v-icon>
|
|
|
+ </span>
|
|
|
+
|
|
|
+ <span>{{$t(child.label)}}</span>
|
|
|
+ </v-list-item-title>
|
|
|
+ </v-list-item>
|
|
|
+
|
|
|
+ </template>
|
|
|
+ </v-list>
|
|
|
+ </v-card-text>
|
|
|
|
|
|
+ <v-card-actions v-if="menu.actions.length > 0" class="ma-0 pa-0 actions">
|
|
|
+ <template v-for="(action, index) in menu.actions" :key="index">
|
|
|
+ <v-list-item
|
|
|
+ :id="action.label"
|
|
|
+ :href="!isInternalLink(action) ? action.to : undefined"
|
|
|
+ :to="isInternalLink(action) ? action.to : undefined"
|
|
|
+ >
|
|
|
+ <v-list-item-title class="text-body-2" v-text="$t(action.label)"/>
|
|
|
+ </v-list-item>
|
|
|
+ </template>
|
|
|
+ </v-card-actions>
|
|
|
+ </v-card>
|
|
|
+ </v-menu>
|
|
|
+ </v-btn>
|
|
|
+ </template>
|
|
|
+ </v-tooltip>
|
|
|
|
|
|
- </v-menu>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts">
|
|
|
-import {defineComponent, useContext} from '@nuxtjs/composition-api'
|
|
|
-import {accessState} from "~/types/interfaces";
|
|
|
+<script setup lang="ts">
|
|
|
+import {useMenu} from "~/composables/layout/useMenu";
|
|
|
+import {computed} from "@vue/reactivity";
|
|
|
|
|
|
-export default defineComponent({
|
|
|
- props: {
|
|
|
- menu: {
|
|
|
- type: Object,
|
|
|
- required: true
|
|
|
- }
|
|
|
+const props = defineProps({
|
|
|
+ name: {
|
|
|
+ type: String,
|
|
|
+ required: true
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+const { buildMenu, isInternalLink, hasMenu, setMenuState, isMenuOpened } = useMenu()
|
|
|
+
|
|
|
+const menu = buildMenu(props.name)
|
|
|
+const displayMenu = computed(() => hasMenu(props.name))
|
|
|
+const isOpened = () => isMenuOpened(props.name)
|
|
|
+
|
|
|
+const onStateUpdated = (e: any) => {
|
|
|
+ console.log(props.name, menu.value.label)
|
|
|
+ setMenuState(props.name, e)
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
-<style scoped>
|
|
|
- #logout{
|
|
|
- background: var(--v-theme-ot-green, white);
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+ .actions {
|
|
|
+ background: rgb(var(--v-theme-ot-green));
|
|
|
color: white;
|
|
|
}
|
|
|
</style>
|