configurationMenuBuilder.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. if (this.ability.can('display', 'organization_page')) {
  16. children.push(
  17. this.createItem(
  18. 'organization_page',
  19. undefined,
  20. UrlUtils.join(
  21. '/main/organizations',
  22. this.organizationProfile.id ?? '',
  23. '/dashboard',
  24. ),
  25. MENU_LINK_TYPE.V1,
  26. ),
  27. )
  28. }
  29. // if (this.ability.can('display', 'cmf_licence_page')) {
  30. // children.push(
  31. // this.createItem(
  32. // 'cmf_licence_generate',
  33. // undefined,
  34. // '/cmf_licence_structure',
  35. // MENU_LINK_TYPE.INTERNAL,
  36. // ),
  37. // )
  38. // }
  39. if (this.ability.can('display', 'cmf_licence_page')) {
  40. children.push(
  41. this.createItem(
  42. 'cmf_licence_generate',
  43. undefined,
  44. '/licence_cmf/organization',
  45. MENU_LINK_TYPE.V1,
  46. ),
  47. )
  48. }
  49. // if (this.ability.can('display', 'parameters_page')) {
  50. // children.push(
  51. // this.createItem(
  52. // 'parameters',
  53. // undefined,
  54. // `/parameters`,
  55. // MENU_LINK_TYPE.INTERNAL,
  56. // ),
  57. // )
  58. // }
  59. children.push(...this.makeChildren([{ pageName: 'parameters_page' }]))
  60. if (this.ability.can('display', 'place_page')) {
  61. children.push(
  62. this.createItem(
  63. 'places',
  64. undefined,
  65. '/places/list/',
  66. MENU_LINK_TYPE.V1,
  67. ),
  68. )
  69. }
  70. if (this.ability.can('display', 'education_page')) {
  71. children.push(
  72. this.createItem(
  73. 'education',
  74. undefined,
  75. '/educations/list/',
  76. MENU_LINK_TYPE.V1,
  77. ),
  78. )
  79. }
  80. if (this.ability.can('display', 'tag_page')) {
  81. children.push(
  82. this.createItem('tags', undefined, '/taggs/list/', MENU_LINK_TYPE.V1),
  83. )
  84. }
  85. if (this.ability.can('display', 'activities_page')) {
  86. children.push(
  87. this.createItem(
  88. 'activities',
  89. undefined,
  90. '/activities/list/',
  91. MENU_LINK_TYPE.V1,
  92. ),
  93. )
  94. }
  95. if (this.ability.can('display', 'template_systems_page')) {
  96. children.push(
  97. this.createItem(
  98. 'template_systems',
  99. undefined,
  100. '/template_systems/list/',
  101. MENU_LINK_TYPE.V1,
  102. ),
  103. )
  104. }
  105. if (this.ability.can('display', 'billing_settings_page')) {
  106. children.push(
  107. this.createItem(
  108. 'billing_settings',
  109. undefined,
  110. UrlUtils.join(
  111. '/main/edit/billing_settings/',
  112. this.organizationProfile.id ?? '',
  113. ),
  114. MENU_LINK_TYPE.V1,
  115. ),
  116. )
  117. }
  118. if (this.ability.can('display', 'online_registration_settings_page')) {
  119. children.push(
  120. this.createItem(
  121. 'online_registration_settings',
  122. undefined,
  123. UrlUtils.join(
  124. '/main/edit/online_registration_settings/',
  125. this.organizationProfile.id ?? '',
  126. ),
  127. MENU_LINK_TYPE.V1,
  128. ),
  129. )
  130. }
  131. if (this.ability.can('display', 'course_duplication_page')) {
  132. children.push(
  133. this.createItem(
  134. 'course_duplication',
  135. undefined,
  136. '/duplicate_courses',
  137. MENU_LINK_TYPE.V1,
  138. ),
  139. )
  140. }
  141. if (this.ability.can('display', 'import_page')) {
  142. children.push(
  143. this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1),
  144. )
  145. }
  146. if (this.ability.can('display', 'parcours_page')) {
  147. children.push(
  148. this.createItem(
  149. 'parcours',
  150. undefined,
  151. '/family_quotient_models/list/',
  152. MENU_LINK_TYPE.V1,
  153. ),
  154. )
  155. }
  156. if (this.ability.can('display', 'family_quotient_models_page')) {
  157. children.push(
  158. this.createItem(
  159. 'family_quotient_models',
  160. undefined,
  161. '/family_quotient_models/list/',
  162. MENU_LINK_TYPE.V1,
  163. ),
  164. )
  165. }
  166. if (this.ability.can('display', 'billing_schedules_settings_page')) {
  167. children.push(
  168. this.createItem(
  169. 'billing_schedules',
  170. undefined,
  171. '/bill_schedules/list/',
  172. MENU_LINK_TYPE.V1,
  173. ),
  174. )
  175. }
  176. if (this.ability.can('display', 'pseudonymization_page')) {
  177. children.push(
  178. this.createItem(
  179. 'pseudonymization',
  180. undefined,
  181. '/pseudonymizationList/list/',
  182. MENU_LINK_TYPE.V1,
  183. ),
  184. )
  185. }
  186. if (children.length > 1) {
  187. // Plusieurs éléments, on retourne un groupe
  188. return this.createGroup(
  189. 'configuration',
  190. { name: 'fas fa-cogs' },
  191. children,
  192. )
  193. } else if (children.length === 1) {
  194. // Un seul élément, on retourne cet élément seul
  195. return children[0]
  196. }
  197. return null
  198. }
  199. }