configurationMenuBuilder.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. import UrlUtils from '~/services/utils/urlUtils'
  5. /**
  6. * Classe pour la construction du Menu Paramètres
  7. */
  8. export default class ConfigurationMenuBuilder extends AbstractMenuBuilder {
  9. static override readonly menuName = 'Configuration'
  10. /**
  11. * Construit le menu Header Configuration ou null si aucune page accessible
  12. */
  13. build(): MenuItem | MenuGroup | null {
  14. const children: MenuItems = []
  15. // 1. "Fiche de la structure" -> 'organization_page'
  16. if (this.ability.can('display', 'organization_page')) {
  17. children.push(
  18. this.createItem(
  19. 'organization_page',
  20. undefined,
  21. UrlUtils.join(
  22. '/main/organizations',
  23. this.organizationProfile.id ?? '',
  24. '/dashboard',
  25. ),
  26. MENU_LINK_TYPE.V1,
  27. ),
  28. )
  29. }
  30. // 2. "Préférences" -> 'parameters_page'
  31. children.push(
  32. ...this.makeChildren([
  33. { pageName: 'parameters_page', endOfSubsection: true },
  34. ]),
  35. )
  36. // 3. "Enseignements" -> 'education'
  37. if (this.ability.can('display', 'education_page')) {
  38. children.push(
  39. this.createItem(
  40. 'education',
  41. undefined,
  42. '/educations/list/',
  43. MENU_LINK_TYPE.V1,
  44. ),
  45. )
  46. }
  47. // 4. "Parcours" -> 'parcours'
  48. if (this.ability.can('display', 'parcours_page')) {
  49. children.push(
  50. this.createItem(
  51. 'parcours',
  52. undefined,
  53. '/education_curriculum_packs/list/',
  54. MENU_LINK_TYPE.V1,
  55. ),
  56. )
  57. }
  58. // 5. "Sections" -> 'activities'
  59. if (this.ability.can('display', 'activities_page')) {
  60. children.push(
  61. this.createItem(
  62. 'activities',
  63. undefined,
  64. '/activities/list/',
  65. MENU_LINK_TYPE.V1,
  66. ),
  67. )
  68. }
  69. // 6. "Préinscription(s) en ligne" -> 'online_registration_settings'
  70. if (this.ability.can('display', 'online_registration_settings_page')) {
  71. children.push(
  72. this.createItem(
  73. 'online_registration_settings',
  74. undefined,
  75. UrlUtils.join(
  76. '/main/edit/online_registration_settings/',
  77. this.organizationProfile.id ?? '',
  78. ),
  79. MENU_LINK_TYPE.V1,
  80. ),
  81. )
  82. }
  83. // 7. "Dupliquer les cours hebdomadaires" -> 'course_duplication'
  84. if (this.ability.can('display', 'course_duplication_page')) {
  85. children.push(
  86. this.createItem(
  87. 'course_duplication',
  88. undefined,
  89. '/duplicate_courses',
  90. MENU_LINK_TYPE.V1,
  91. false,
  92. true,
  93. ),
  94. )
  95. }
  96. // 8. "Facturation" -> 'billing_settings'
  97. if (this.ability.can('display', 'billing_settings_page')) {
  98. children.push(
  99. this.createItem(
  100. 'billing_settings',
  101. undefined,
  102. UrlUtils.join(
  103. '/main/edit/billing_settings/',
  104. this.organizationProfile.id ?? '',
  105. ),
  106. MENU_LINK_TYPE.V1,
  107. ),
  108. )
  109. }
  110. // 9. "Liste des produits" -> 'billing_product'
  111. if (this.ability.can('display', 'billing_product_page')) {
  112. children.push(
  113. this.createItem(
  114. 'billing_product',
  115. undefined,
  116. '/intangibles/list/',
  117. MENU_LINK_TYPE.V1,
  118. ),
  119. )
  120. }
  121. // 10. "Modèles de quotients familiaux" -> 'family_quotient_models'
  122. if (this.ability.can('display', 'family_quotient_models_page')) {
  123. children.push(
  124. this.createItem(
  125. 'family_quotient_models',
  126. undefined,
  127. '/family_quotient_models/list/',
  128. MENU_LINK_TYPE.V1,
  129. ),
  130. )
  131. }
  132. // 11. "Echéanciers de facturation" -> 'billing_schedules'
  133. if (this.ability.can('display', 'billing_schedules_settings_page')) {
  134. children.push(
  135. this.createItem(
  136. 'billing_schedules',
  137. undefined,
  138. '/bill_schedules/list/',
  139. MENU_LINK_TYPE.V1,
  140. false,
  141. true,
  142. ),
  143. )
  144. }
  145. // 12. "Lieux" -> 'places'
  146. if (this.ability.can('display', 'place_page')) {
  147. children.push(
  148. this.createItem(
  149. 'places',
  150. undefined,
  151. '/places/list/',
  152. MENU_LINK_TYPE.V1,
  153. ),
  154. )
  155. }
  156. // 13. "Mails système" -> 'template_systems'
  157. if (this.ability.can('display', 'template_systems_page')) {
  158. children.push(
  159. this.createItem(
  160. 'template_systems',
  161. undefined,
  162. '/template_systems/list/',
  163. MENU_LINK_TYPE.V1,
  164. ),
  165. )
  166. }
  167. // 14. "Pseudonymisation" -> 'pseudonymization'
  168. if (this.ability.can('display', 'pseudonymization_page')) {
  169. children.push(
  170. this.createItem(
  171. 'pseudonymization',
  172. undefined,
  173. '/pseudonymizationList/list/',
  174. MENU_LINK_TYPE.V1,
  175. ),
  176. )
  177. }
  178. // 15. "Tags" -> 'tags'
  179. if (this.ability.can('display', 'tag_page')) {
  180. children.push(
  181. this.createItem('tags', undefined, '/taggs/list/', MENU_LINK_TYPE.V1),
  182. )
  183. }
  184. // 16. "Importer" -> 'import'
  185. if (this.ability.can('display', 'import_page')) {
  186. children.push(
  187. this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1),
  188. )
  189. }
  190. // CMF licence (not in the required order, but keeping it at the end)
  191. if (this.ability.can('display', 'cmf_licence_page')) {
  192. children.push(
  193. this.createItem(
  194. 'cmf_licence_generate',
  195. undefined,
  196. '/licence_cmf/organization',
  197. MENU_LINK_TYPE.V1,
  198. ),
  199. )
  200. }
  201. if (children.length > 1) {
  202. // Plusieurs éléments, on retourne un groupe
  203. return this.createGroup(
  204. 'configuration',
  205. { name: 'fas fa-cogs' },
  206. children,
  207. )
  208. } else if (children.length === 1) {
  209. // Un seul élément, on retourne cet élément seul
  210. return children[0]
  211. }
  212. return null
  213. }
  214. }