configurationMenuBuilder.ts 6.0 KB

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