configurationMenu.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * Construit le menu Header Configuration ou null si aucune page accessible
  13. * @return {ItemMenu | null}
  14. */
  15. getHeaderMenu (): ItemMenu | null {
  16. const {can} = useAbility()
  17. const profileOrganizationStore = useProfileOrganizationStore()
  18. const children: ItemsMenu = []
  19. if (can('display', 'organization_page')) {
  20. // children.push(this.constructMenu('organization_page', undefined, `/main/organizations/${profileOrganizationStore.id}/dashboard`, true))
  21. children.push(this.constructMenuItem('organization_page', undefined, `/organization`, false))
  22. }
  23. if (can('display', 'cmf_licence_page')) {
  24. children.push(this.constructMenuItem('cmf_licence_generate', undefined, '/cmf_licence/organization'))
  25. }
  26. if (can('display', 'parameters_page')) {
  27. // children.push(this.constructMenu('parameters', undefined,`/main/edit/parameters/${profileOrganizationStore.id}`, true))
  28. children.push(this.constructMenuItem('parameters', undefined,`/parameters`, false))
  29. }
  30. if (can('display', 'place_page')) {
  31. children.push(this.constructMenuItem('place', undefined, '/places/list/', true))
  32. }
  33. if (can('display', 'education_page')) {
  34. children.push(this.constructMenuItem('education', undefined, '/educations/list/', true))
  35. }
  36. if (can('display', 'tag_page')) {
  37. children.push(this.constructMenuItem('tag', undefined, '/taggs/list/', true))
  38. }
  39. if (can('display', 'activities_page')) {
  40. children.push(this.constructMenuItem('activities', undefined, '/activities/list/', true))
  41. }
  42. if (can('display', 'template_systems_page')) {
  43. children.push(this.constructMenuItem('template_systems', undefined,'/template_systems/list/', true))
  44. }
  45. if (can('display', 'billing_settings_page')) {
  46. children.push(this.constructMenuItem('billing_settings', undefined, '/main/edit/billing_settings/' + profileOrganizationStore.id, true))
  47. }
  48. if (can('display', 'online_registration_settings_page')) {
  49. children.push(this.constructMenuItem('online_registration_settings', undefined, '/main/edit/online_registration_settings/' + profileOrganizationStore.id, true))
  50. }
  51. if (can('display', 'transition_next_year_page')) {
  52. children.push(this.constructMenuItem('transition_next_year', undefined, '/transition_next_year', true))
  53. }
  54. if (can('display', 'course_duplication_page')) {
  55. children.push(this.constructMenuItem('course_duplication', undefined, '/duplicate_courses', true))
  56. }
  57. if (can('display', 'import_page')) {
  58. children.push(this.constructMenuItem('import', undefined, '/import/all', true))
  59. }
  60. if (children.length === 1) {
  61. return children[0]
  62. } else if (children.length > 0) {
  63. return this.constructMenuItem('configuration', {name: 'fa-cogs'}, undefined, undefined, children)
  64. } else {
  65. return null
  66. }
  67. }
  68. }
  69. export const getConfigurationMenu = () => new ConfigurationMenu().getHeaderMenu()