Menu.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!--
  2. Menu déroulant générique pour l'affichage des menus du
  3. header principal (configuration, paramètres du compte...)
  4. -->
  5. <template>
  6. <v-menu offset-y left>
  7. <template #activator="{ on: { click }, attrs }">
  8. <v-tooltip bottom>
  9. <template #activator="{ on: on_tooltips , attrs: attrs_tooltips }">
  10. <v-btn
  11. icon
  12. v-bind="[attrs, attrs_tooltips]"
  13. color=""
  14. v-on="on_tooltips"
  15. @click="click"
  16. >
  17. <v-avatar
  18. v-if="avatar"
  19. size="30"
  20. >
  21. <UiImage :id="avatarId" :imageByDefault="avatarByDefault" :width="30"></UiImage>
  22. </v-avatar>
  23. <v-icon v-else class="ot_white--text" small>
  24. {{ menu.icon }}
  25. </v-icon>
  26. </v-btn>
  27. </template>
  28. <span>{{ $t(menu.title) }}</span>
  29. </v-tooltip>
  30. </template>
  31. <v-card scrollable>
  32. <v-card-title class="ot_header_menu text-body-2 font-weight-bold">
  33. {{$t(menu.title)}}
  34. </v-card-title>
  35. <v-card-text class="ma-0 pa-0 header_menu">
  36. <v-list dense :subheader="true">
  37. <template v-for="(item, index) in menu.children">
  38. <v-list-item
  39. :id="item.title"
  40. :key="index"
  41. :href="item.isExternalLink ? item.to : undefined"
  42. :to="!item.isExternalLink ? item.to : undefined"
  43. router
  44. exact
  45. >
  46. <v-list-item-title v-text="$t(item.title)"/>
  47. </v-list-item>
  48. </template>
  49. </v-list>
  50. </v-card-text>
  51. <v-card-actions class="ma-0 pa-0">
  52. <template v-for="(item, index) in menu.actions">
  53. <v-list-item
  54. :id="item.title"
  55. :key="index"
  56. :href="item.isExternalLink ? item.to : undefined"
  57. :to="!item.isExternalLink ? item.to : undefined"
  58. router
  59. >
  60. <v-list-item-title class="text-body-2 ot_white--text" v-text="$t(item.title)"/>
  61. </v-list-item>
  62. </template>
  63. </v-card-actions>
  64. </v-card>
  65. </v-menu>
  66. </template>
  67. <script lang="ts">
  68. import {defineComponent, useContext} from '@nuxtjs/composition-api'
  69. import {accessState} from "~/types/interfaces";
  70. export default defineComponent({
  71. props: {
  72. menu: {
  73. type: Object,
  74. required: true
  75. },
  76. avatar: {
  77. type: Boolean,
  78. required: false
  79. }
  80. },
  81. setup () {
  82. const {store} = useContext()
  83. const accessStore: accessState = store.state.profile.access
  84. return {
  85. avatarId: accessStore.avatarId,
  86. avatarByDefault: accessStore.gender == 'MISTER' ? 'men-1.png' : 'women-1.png'
  87. }
  88. }
  89. })
  90. </script>
  91. <style scoped>
  92. #logout{
  93. background: var(--v-ot_green-base, white);
  94. color: white;
  95. }
  96. </style>