educationalMenu.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
  2. import BaseMenu from '~/composables/layout/Menus/baseMenu'
  3. import {useAbility} from "@casl/vue";
  4. /**
  5. * @category composables/layout/Menus
  6. * @class EducationalMenu
  7. * Classe pour la construction du Menu Suivi pédagogique
  8. */
  9. class EducationalMenu extends BaseMenu implements Menu {
  10. /**
  11. * @constructor
  12. * Initialisation des services issues du context
  13. */
  14. constructor () {
  15. const {$config} = useNuxtApp()
  16. super($config)
  17. }
  18. /**
  19. * Construit le menu Suivi pédagogique ou null si aucune page accessible
  20. * @return {ItemMenu | null}
  21. */
  22. getMenu (): ItemMenu | null {
  23. const {can} = useAbility()
  24. const children: ItemsMenu = []
  25. if (can('display', 'criteria_notations_page')) {
  26. children.push(this.constructMenu('criteria_notations', {name: 'fa-bars'}, '/criteria_notations/list/', true))
  27. }
  28. if (can('display', 'education_notation_config_page')) {
  29. children.push(this.constructMenu('education_notation_configs', {name: 'fa-bars'}, '/education_notation_configs/list/', true))
  30. }
  31. if (can('display', 'seizure_period_page')) {
  32. children.push(this.constructMenu('seizure_period', {name: 'fa-calendar-alt'}, '/education_teachers/list/', true))
  33. }
  34. if (can('display', 'test_seizure_page')) {
  35. children.push(this.constructMenu('test_seizure', {name: 'fa-pencil-alt'}, '/education_input/list/', true))
  36. }
  37. if (can('display', 'test_validation_page')) {
  38. children.push(this.constructMenu('test_validation', {name: 'fa-check'}, '/education_notations/list/', true))
  39. }
  40. if (can('display', 'examen_results_page')) {
  41. children.push(this.constructMenu('examen_results', {name: 'fa-graduation-cap'}, '/examen_convocations/list/', true))
  42. }
  43. if (can('display', 'education_by_student_validation_page')) {
  44. children.push(this.constructMenu('education_by_student_validation', {name: 'fa-check-square'}, '/education_by_student/list/', true))
  45. }
  46. if (children.length === 1) {
  47. return children[0]
  48. } else if (children.length > 0) {
  49. return this.constructMenu('education_state', {name: 'fa-graduation-cap'}, undefined, undefined, children)
  50. } else {
  51. return null
  52. }
  53. }
  54. }
  55. export const getEducationalMenu = () => new EducationalMenu().getMenu()