educationalMenuBuilder.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
  3. import { MENU_LINK_TYPE } from '~/types/enum/layout'
  4. /**
  5. * Menu Suivi pédagogique
  6. */
  7. export default class EducationalMenuBuilder extends AbstractMenuBuilder {
  8. static override readonly menuName = 'Educational'
  9. /**
  10. * Construit le menu Suivi pédagogique ou null si aucune page accessible
  11. */
  12. build(): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'criteria_notations_page')) {
  15. children.push(
  16. this.createItem(
  17. 'criteria_notations',
  18. { name: 'fas fa-bars' },
  19. '/criteria_notations/list/',
  20. MENU_LINK_TYPE.V1,
  21. ),
  22. )
  23. }
  24. if (this.ability.can('display', 'education_notation_config_page')) {
  25. children.push(
  26. this.createItem(
  27. 'education_notation_configs',
  28. { name: 'fas fa-bars' },
  29. '/education_notation_configs/list/',
  30. MENU_LINK_TYPE.V1,
  31. ),
  32. )
  33. }
  34. if (this.ability.can('display', 'seizure_period_page')) {
  35. children.push(
  36. this.createItem(
  37. 'seizure_period',
  38. { name: 'fas fa-calendar-alt' },
  39. '/education_teachers/list/',
  40. MENU_LINK_TYPE.V1,
  41. ),
  42. )
  43. }
  44. if (this.ability.can('display', 'test_seizure_page')) {
  45. children.push(
  46. this.createItem(
  47. 'test_seizure',
  48. { name: 'fas fa-pencil-alt' },
  49. '/education_input/list/',
  50. MENU_LINK_TYPE.V1,
  51. ),
  52. )
  53. }
  54. if (this.ability.can('display', 'test_validation_page')) {
  55. children.push(
  56. this.createItem(
  57. 'test_validation',
  58. { name: 'fas fa-check' },
  59. '/education_notations/list/',
  60. MENU_LINK_TYPE.V1,
  61. ),
  62. )
  63. }
  64. if (this.ability.can('display', 'examen_results_page')) {
  65. children.push(
  66. this.createItem(
  67. 'examen_results',
  68. { name: 'fas fa-graduation-cap' },
  69. '/examen_convocations/list/',
  70. MENU_LINK_TYPE.V1,
  71. ),
  72. )
  73. }
  74. if (this.ability.can('display', 'education_by_student_validation_page')) {
  75. children.push(
  76. this.createItem(
  77. 'education_by_student_validation',
  78. { name: 'fas fa-check-square' },
  79. '/education_by_student/list/',
  80. MENU_LINK_TYPE.V1,
  81. ),
  82. )
  83. }
  84. if (children.length > 1) {
  85. // Plusieurs éléments, on retourne un groupe
  86. return this.createGroup(
  87. 'education_state',
  88. { name: 'fas fa-graduation-cap' },
  89. children,
  90. )
  91. } else if (children.length === 1) {
  92. // Un seul élément, on retourne cet élément seul
  93. return children[0]
  94. }
  95. return null
  96. }
  97. }