cotisationsMenuBuilder.ts 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import AbstractMenuBuilder from '~/services/menuBuilder/abstractMenuBuilder'
  2. import {MenuItems, MENU_LINK_TYPE, MenuGroup, MenuItem} from "~/types/menus";
  3. /**
  4. * Menu Cotisation (CMF)
  5. */
  6. export default class CotisationsMenuBuilder extends AbstractMenuBuilder {
  7. name() {
  8. return 'Cotisation'
  9. }
  10. /**
  11. * Construit le menu Cotisations ou null si aucune page accessible
  12. */
  13. build (): MenuItem | MenuGroup | null {
  14. const children: MenuItems = []
  15. if (this.ability.can('display', 'rate_cotisation_page')) {
  16. children.push(this.createItem('rate_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/rate', MENU_LINK_TYPE.V1))
  17. }
  18. if (this.ability.can('display', 'parameters_cotisation_page')) {
  19. children.push(this.createItem('parameters_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/parameter', MENU_LINK_TYPE.V1))
  20. }
  21. if (this.ability.can('display', 'send_cotisation_page')) {
  22. children.push(this.createItem('send_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/send', MENU_LINK_TYPE.V1))
  23. }
  24. if (this.ability.can('display', 'state_cotisation_page')) {
  25. children.push(this.createItem('state_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/state', MENU_LINK_TYPE.V1))
  26. }
  27. if (this.ability.can('display', 'pay_cotisation_page')) {
  28. children.push(this.createItem('pay_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/pay', MENU_LINK_TYPE.V1))
  29. }
  30. if (this.ability.can('display', 'check_cotisation_page')) {
  31. children.push(this.createItem('check_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/check', MENU_LINK_TYPE.V1))
  32. }
  33. if (this.ability.can('display', 'ledger_cotisation_page')) {
  34. children.push(this.createItem('ledger_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/ledger', MENU_LINK_TYPE.V1))
  35. }
  36. if (this.ability.can('display', 'magazine_cotisation_page')) {
  37. children.push(this.createItem('magazine_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/magazine', MENU_LINK_TYPE.V1))
  38. }
  39. if (this.ability.can('display', 'ventilated_cotisation_page')) {
  40. children.push(this.createItem('ventilated_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/ventilated', MENU_LINK_TYPE.V1))
  41. }
  42. if (this.ability.can('display', 'pay_erase_cotisation_page')) {
  43. children.push(this.createItem('pay_erase_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/payerase', MENU_LINK_TYPE.V1))
  44. }
  45. if (this.ability.can('display', 'resume_cotisation_page')) {
  46. children.push(this.createItem('resume_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/resume', MENU_LINK_TYPE.V1))
  47. }
  48. if (this.ability.can('display', 'history_cotisation_page')) {
  49. children.push(this.createItem('history_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/history', MENU_LINK_TYPE.V1))
  50. }
  51. if (this.ability.can('display', 'call_cotisation_page')) {
  52. children.push(this.createItem('call_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/call', MENU_LINK_TYPE.V1))
  53. }
  54. if (this.ability.can('display', 'history_structure_cotisation_page')) {
  55. children.push(this.createItem('history_structure_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/historystructure', MENU_LINK_TYPE.V1))
  56. }
  57. if (this.ability.can('display', 'insurance_cotisation_page')) {
  58. children.push(this.createItem('insurance_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/insurance', MENU_LINK_TYPE.V1))
  59. }
  60. if (this.ability.can('display', 'resume_all_cotisation_page')) {
  61. children.push(this.createItem('resume_all_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/resumeall', MENU_LINK_TYPE.V1))
  62. }
  63. if (this.ability.can('display', 'resume_pay_cotisation_page')) {
  64. children.push(this.createItem('resume_pay_cotisation', {name: 'fas fa-euro-sign'}, '/cotisation/resumepay', MENU_LINK_TYPE.V1))
  65. }
  66. if (children.length > 1) {
  67. // Plusieurs éléments, on retourne un groupe
  68. return this.createGroup('cotisations', {name: 'fas fa-money-bill'}, children)
  69. }
  70. else if (children.length === 1) {
  71. // Un seul élément, on retourne cet élément seul
  72. return children[0]
  73. }
  74. return null
  75. }
  76. }