configurationMenuBuilder.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 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. if (this.ability.can('display', 'parameters_page')) {
  60. children.push(
  61. this.createItem(
  62. 'parameters',
  63. undefined,
  64. `/main/edit/parameters/${this.organizationProfile.id}`,
  65. MENU_LINK_TYPE.V1,
  66. ),
  67. )
  68. }
  69. if (this.ability.can('display', 'place_page')) {
  70. children.push(
  71. this.createItem(
  72. 'places',
  73. undefined,
  74. '/places/list/',
  75. MENU_LINK_TYPE.V1,
  76. ),
  77. )
  78. }
  79. if (this.ability.can('display', 'education_page')) {
  80. children.push(
  81. this.createItem(
  82. 'education',
  83. undefined,
  84. '/educations/list/',
  85. MENU_LINK_TYPE.V1,
  86. ),
  87. )
  88. }
  89. if (this.ability.can('display', 'tag_page')) {
  90. children.push(
  91. this.createItem('tags', undefined, '/taggs/list/', MENU_LINK_TYPE.V1),
  92. )
  93. }
  94. if (this.ability.can('display', 'activities_page')) {
  95. children.push(
  96. this.createItem(
  97. 'activities',
  98. undefined,
  99. '/activities/list/',
  100. MENU_LINK_TYPE.V1,
  101. ),
  102. )
  103. }
  104. if (this.ability.can('display', 'template_systems_page')) {
  105. children.push(
  106. this.createItem(
  107. 'template_systems',
  108. undefined,
  109. '/template_systems/list/',
  110. MENU_LINK_TYPE.V1,
  111. ),
  112. )
  113. }
  114. if (this.ability.can('display', 'billing_settings_page')) {
  115. children.push(
  116. this.createItem(
  117. 'billing_settings',
  118. undefined,
  119. UrlUtils.join(
  120. '/main/edit/billing_settings/',
  121. this.organizationProfile.id ?? '',
  122. ),
  123. MENU_LINK_TYPE.V1,
  124. ),
  125. )
  126. }
  127. if (this.ability.can('display', 'billing_schedules_settings_page')) {
  128. children.push(
  129. this.createItem(
  130. 'billing_schedules',
  131. undefined,
  132. '/bill_schedules/list/',
  133. MENU_LINK_TYPE.V1,
  134. ),
  135. )
  136. }
  137. if (this.ability.can('display', 'online_registration_settings_page')) {
  138. children.push(
  139. this.createItem(
  140. 'online_registration_settings',
  141. undefined,
  142. UrlUtils.join(
  143. '/main/edit/online_registration_settings/',
  144. this.organizationProfile.id ?? '',
  145. ),
  146. MENU_LINK_TYPE.V1,
  147. ),
  148. )
  149. }
  150. if (this.ability.can('display', 'course_duplication_page')) {
  151. children.push(
  152. this.createItem(
  153. 'course_duplication',
  154. undefined,
  155. '/duplicate_courses',
  156. MENU_LINK_TYPE.V1,
  157. ),
  158. )
  159. }
  160. if (this.ability.can('display', 'import_page')) {
  161. children.push(
  162. this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1),
  163. )
  164. }
  165. if (children.length > 1) {
  166. // Plusieurs éléments, on retourne un groupe
  167. return this.createGroup(
  168. 'configuration',
  169. { name: 'fas fa-cogs' },
  170. children,
  171. )
  172. } else if (children.length === 1) {
  173. // Un seul élément, on retourne cet élément seul
  174. return children[0]
  175. }
  176. return null
  177. }
  178. }