cotisationsMenuBuilder.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 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(this.createItem('rate_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/rate', MENU_LINK_TYPE.V1))
  16. }
  17. if (this.ability.can('display', 'parameters_cotisation_page')) {
  18. children.push(this.createItem('parameters_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/parameter', MENU_LINK_TYPE.V1))
  19. }
  20. if (this.ability.can('display', 'send_cotisation_page')) {
  21. children.push(this.createItem('send_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/send', MENU_LINK_TYPE.V1))
  22. }
  23. if (this.ability.can('display', 'state_cotisation_page')) {
  24. children.push(this.createItem('state_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/state', MENU_LINK_TYPE.V1))
  25. }
  26. if (this.ability.can('display', 'pay_cotisation_page')) {
  27. children.push(this.createItem('pay_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/pay', MENU_LINK_TYPE.V1))
  28. }
  29. if (this.ability.can('display', 'check_cotisation_page')) {
  30. children.push(this.createItem('check_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/check', MENU_LINK_TYPE.V1))
  31. }
  32. if (this.ability.can('display', 'ledger_cotisation_page')) {
  33. children.push(this.createItem('ledger_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/ledger', MENU_LINK_TYPE.V1))
  34. }
  35. if (this.ability.can('display', 'magazine_cotisation_page')) {
  36. children.push(this.createItem('magazine_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/magazine', MENU_LINK_TYPE.V1))
  37. }
  38. if (this.ability.can('display', 'ventilated_cotisation_page')) {
  39. children.push(this.createItem('ventilated_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/ventilated', MENU_LINK_TYPE.V1))
  40. }
  41. if (this.ability.can('display', 'pay_erase_cotisation_page')) {
  42. children.push(this.createItem('pay_erase_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/payerase', MENU_LINK_TYPE.V1))
  43. }
  44. if (this.ability.can('display', 'resume_cotisation_page')) {
  45. children.push(this.createItem('resume_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/resume', MENU_LINK_TYPE.V1))
  46. }
  47. if (this.ability.can('display', 'history_cotisation_page')) {
  48. children.push(this.createItem('history_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/history', MENU_LINK_TYPE.V1))
  49. }
  50. if (this.ability.can('display', 'call_cotisation_page')) {
  51. children.push(this.createItem('call_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/call', MENU_LINK_TYPE.V1))
  52. }
  53. if (this.ability.can('display', 'history_structure_cotisation_page')) {
  54. children.push(this.createItem('history_structure_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/historystructure', MENU_LINK_TYPE.V1))
  55. }
  56. if (this.ability.can('display', 'insurance_cotisation_page')) {
  57. children.push(this.createItem('insurance_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/insurance', MENU_LINK_TYPE.V1))
  58. }
  59. if (this.ability.can('display', 'resume_all_cotisation_page')) {
  60. children.push(this.createItem('resume_all_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/resumeall', MENU_LINK_TYPE.V1))
  61. }
  62. if (this.ability.can('display', 'resume_pay_cotisation_page')) {
  63. children.push(this.createItem('resume_pay_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/resumepay', MENU_LINK_TYPE.V1))
  64. }
  65. if (children.length > 1) {
  66. // Plusieurs éléments, on retourne un groupe
  67. return this.createGroup('cotisations', {name: 'fas fa-money-bill'}, children)
  68. }
  69. else if (children.length === 1) {
  70. // Un seul élément, on retourne cet élément seul
  71. return children[0]
  72. }
  73. return null
  74. }
  75. }