cotisationsMenuBuilder.ts 4.2 KB

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