configurationMenu.ts 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
  2. import BaseMenu from '~/composables/layout/Menus/baseMenu'
  3. import {useProfileOrganizationStore} from "~/store/profile/organization";
  4. import {useAbility} from "@casl/vue";
  5. /**
  6. * @category composables/layout/Menus
  7. * @class ConfigurationMenu
  8. * Classe pour la construction du Menu Paramètres
  9. */
  10. class ConfigurationMenu extends BaseMenu implements Menu {
  11. /**
  12. * @constructor
  13. * Initialisation des services issues du context
  14. */
  15. constructor () {
  16. const {$config} = useNuxtApp()
  17. super($config)
  18. }
  19. /**
  20. * Construit le menu Header Configuration ou null si aucune page accessible
  21. * @return {ItemMenu | null}
  22. */
  23. getHeaderMenu (): ItemMenu | null {
  24. const {can} = useAbility()
  25. const profileOrganizationStore = useProfileOrganizationStore()
  26. const children: ItemsMenu = []
  27. if (can('display', 'organization_page')) {
  28. // children.push(this.constructMenu('organization_page', undefined, `/main/organizations/${profileOrganizationStore.id}/dashboard`, true))
  29. children.push(this.constructMenu('organization_page', undefined, `/organization`, false))
  30. }
  31. if (can('display', 'cmf_licence_page')) {
  32. children.push(this.constructMenu('cmf_licence_generate', undefined, '/cmf_licence/organization'))
  33. }
  34. if (can('display', 'parameters_page')) {
  35. // children.push(this.constructMenu('parameters', undefined,`/main/edit/parameters/${profileOrganizationStore.id}`, true))
  36. children.push(this.constructMenu('parameters', undefined,`/parameters`, false))
  37. }
  38. if (can('display', 'place_page')) {
  39. children.push(this.constructMenu('place', undefined, '/places/list/', true))
  40. }
  41. if (can('display', 'education_page')) {
  42. children.push(this.constructMenu('education', undefined, '/educations/list/', true))
  43. }
  44. if (can('display', 'tag_page')) {
  45. children.push(this.constructMenu('tag', undefined, '/taggs/list/', true))
  46. }
  47. if (can('display', 'activities_page')) {
  48. children.push(this.constructMenu('activities', undefined, '/activities/list/', true))
  49. }
  50. if (can('display', 'template_systems_page')) {
  51. children.push(this.constructMenu('template_systems', undefined,'/template_systems/list/', true))
  52. }
  53. if (can('display', 'billing_settings_page')) {
  54. children.push(this.constructMenu('billing_settings', undefined, '/main/edit/billing_settings/' + profileOrganizationStore.id, true))
  55. }
  56. if (can('display', 'online_registration_settings_page')) {
  57. children.push(this.constructMenu('online_registration_settings', undefined, '/main/edit/online_registration_settings/' + profileOrganizationStore.id, true))
  58. }
  59. if (can('display', 'transition_next_year_page')) {
  60. children.push(this.constructMenu('transition_next_year', undefined, '/transition_next_year', true))
  61. }
  62. if (can('display', 'course_duplication_page')) {
  63. children.push(this.constructMenu('course_duplication', undefined, '/duplicate_courses', true))
  64. }
  65. if (can('display', 'import_page')) {
  66. children.push(this.constructMenu('import', undefined, '/import/all', true))
  67. }
  68. if (children.length === 1) {
  69. return children[0]
  70. } else if (children.length > 0) {
  71. return this.constructMenu('configuration', {name: 'fa-cogs'}, undefined, undefined, children)
  72. } else {
  73. return null
  74. }
  75. }
  76. }
  77. export const getConfigurationMenu = () => new ConfigurationMenu().getHeaderMenu()