cotisationsMenuBuilder.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import type { MenuItems, MenuGroup, MenuItem } from '~/types/layout'
  3. import { MENU_LINK_TYPE } from '~/types/enum/layout'
  4. /**
  5. * Menu Cotisation (CMF)
  6. */
  7. export default class CotisationsMenuBuilder extends AbstractMenuBuilder {
  8. static override readonly menuName = 'Cotisation'
  9. /**
  10. * Construit le menu Cotisations ou null si aucune page accessible
  11. */
  12. build(): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'rate_cotisation_page')) {
  15. children.push(
  16. this.createItem(
  17. 'rate_cotisation',
  18. { name: 'fas fa-euro-sign' },
  19. '/cotisation/rate',
  20. MENU_LINK_TYPE.V1,
  21. ),
  22. )
  23. }
  24. if (this.ability.can('display', 'parameters_cotisation_page')) {
  25. children.push(
  26. this.createItem(
  27. 'parameters_cotisation',
  28. { name: 'fas fa-euro-sign' },
  29. '/cotisation/parameter',
  30. MENU_LINK_TYPE.V1,
  31. ),
  32. )
  33. }
  34. if (this.ability.can('display', 'send_cotisation_page')) {
  35. children.push(
  36. this.createItem(
  37. 'send_cotisation',
  38. { name: 'fas fa-euro-sign' },
  39. '/cotisation/send',
  40. MENU_LINK_TYPE.V1,
  41. ),
  42. )
  43. }
  44. if (this.ability.can('display', 'state_cotisation_page')) {
  45. children.push(
  46. this.createItem(
  47. 'state_cotisation',
  48. { name: 'fas fa-euro-sign' },
  49. '/cotisation/state',
  50. MENU_LINK_TYPE.V1,
  51. ),
  52. )
  53. }
  54. if (this.ability.can('display', 'pay_cotisation_page')) {
  55. children.push(
  56. this.createItem(
  57. 'pay_cotisation',
  58. { name: 'fas fa-euro-sign' },
  59. '/cotisation/pay',
  60. MENU_LINK_TYPE.V1,
  61. ),
  62. )
  63. }
  64. if (this.ability.can('display', 'check_cotisation_page')) {
  65. children.push(
  66. this.createItem(
  67. 'check_cotisation',
  68. { name: 'fas fa-euro-sign' },
  69. '/cotisation/check',
  70. MENU_LINK_TYPE.V1,
  71. ),
  72. )
  73. }
  74. if (this.ability.can('display', 'ledger_cotisation_page')) {
  75. children.push(
  76. this.createItem(
  77. 'ledger_cotisation',
  78. { name: 'fas fa-euro-sign' },
  79. '/cotisation/ledger',
  80. MENU_LINK_TYPE.V1,
  81. ),
  82. )
  83. }
  84. if (this.ability.can('display', 'magazine_cotisation_page')) {
  85. children.push(
  86. this.createItem(
  87. 'magazine_cotisation',
  88. { name: 'fas fa-euro-sign' },
  89. '/cotisation/magazine',
  90. MENU_LINK_TYPE.V1,
  91. ),
  92. )
  93. }
  94. if (this.ability.can('display', 'ventilated_cotisation_page')) {
  95. children.push(
  96. this.createItem(
  97. 'ventilated_cotisation',
  98. { name: 'fas fa-euro-sign' },
  99. '/cotisation/ventilated',
  100. MENU_LINK_TYPE.V1,
  101. ),
  102. )
  103. }
  104. if (this.ability.can('display', 'pay_erase_cotisation_page')) {
  105. children.push(
  106. this.createItem(
  107. 'pay_erase_cotisation',
  108. { name: 'fas fa-euro-sign' },
  109. '/cotisation/payerase',
  110. MENU_LINK_TYPE.V1,
  111. ),
  112. )
  113. }
  114. if (this.ability.can('display', 'resume_cotisation_page')) {
  115. children.push(
  116. this.createItem(
  117. 'resume_cotisation',
  118. { name: 'fas fa-euro-sign' },
  119. '/cotisation/resume',
  120. MENU_LINK_TYPE.V1,
  121. ),
  122. )
  123. }
  124. if (this.ability.can('display', 'history_cotisation_page')) {
  125. children.push(
  126. this.createItem(
  127. 'history_cotisation',
  128. { name: 'fas fa-euro-sign' },
  129. '/cotisation/history',
  130. MENU_LINK_TYPE.V1,
  131. ),
  132. )
  133. }
  134. if (this.ability.can('display', 'call_cotisation_page')) {
  135. children.push(
  136. this.createItem(
  137. 'call_cotisation',
  138. { name: 'fas fa-euro-sign' },
  139. '/cotisation/call',
  140. MENU_LINK_TYPE.V1,
  141. ),
  142. )
  143. }
  144. if (this.ability.can('display', 'history_structure_cotisation_page')) {
  145. children.push(
  146. this.createItem(
  147. 'history_structure_cotisation',
  148. { name: 'fas fa-euro-sign' },
  149. '/cotisation/historystructure',
  150. MENU_LINK_TYPE.V1,
  151. ),
  152. )
  153. }
  154. if (this.ability.can('display', 'insurance_cotisation_page')) {
  155. children.push(
  156. this.createItem(
  157. 'insurance_cotisation',
  158. { name: 'fas fa-euro-sign' },
  159. '/cotisation/insurance',
  160. MENU_LINK_TYPE.V1,
  161. ),
  162. )
  163. }
  164. if (this.ability.can('display', 'resume_all_cotisation_page')) {
  165. children.push(
  166. this.createItem(
  167. 'resume_all_cotisation',
  168. { name: 'fas fa-euro-sign' },
  169. '/cotisation/resumeall',
  170. MENU_LINK_TYPE.V1,
  171. ),
  172. )
  173. }
  174. if (this.ability.can('display', 'resume_pay_cotisation_page')) {
  175. children.push(
  176. this.createItem(
  177. 'resume_pay_cotisation',
  178. { name: 'fas fa-euro-sign' },
  179. '/cotisation/resumepay',
  180. MENU_LINK_TYPE.V1,
  181. ),
  182. )
  183. }
  184. if (children.length > 1) {
  185. // Plusieurs éléments, on retourne un groupe
  186. return this.createGroup(
  187. 'cotisations',
  188. { name: 'fas fa-money-bill' },
  189. children,
  190. )
  191. } else if (children.length === 1) {
  192. // Un seul élément, on retourne cet élément seul
  193. return children[0]
  194. }
  195. return null
  196. }
  197. }