cotisationsMenu.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
  2. import BaseMenu from '~/composables/layout/Menus/baseMenu'
  3. import {useAbility} from "@casl/vue";
  4. /**
  5. * @category composables/layout/Menus
  6. * @class CotisationsMenu
  7. * Classe pour la construction du Menu Cotisation (CMF)
  8. */
  9. class CotisationsMenu extends BaseMenu implements Menu {
  10. /**
  11. * @constructor
  12. * Initialisation des services issues du context
  13. */
  14. constructor () {
  15. const {$config} = useNuxtApp()
  16. super($config)
  17. }
  18. /**
  19. * Construit le menu Cotisations ou null si aucune page accessible
  20. * @return {ItemMenu | null}
  21. */
  22. getMenu (): ItemMenu | null {
  23. const {can} = useAbility()
  24. const children: ItemsMenu = []
  25. if (can('display', 'rate_cotisation_page')) {
  26. children.push(this.constructMenu('rate_cotisation', {name: 'fa-euro-sign'}, '/cotisation/rate', true))
  27. }
  28. if (can('display', 'parameters_cotisation_page')) {
  29. children.push(this.constructMenu('parameters_cotisation', {name: 'fa-euro-sign'}, '/cotisation/parameter', true))
  30. }
  31. if (can('display', 'send_cotisation_page')) {
  32. children.push(this.constructMenu('send_cotisation', {name: 'fa-euro-sign'}, '/cotisation/send', true))
  33. }
  34. if (can('display', 'state_cotisation_page')) {
  35. children.push(this.constructMenu('state_cotisation', {name: 'fa-euro-sign'}, '/cotisation/state', true))
  36. }
  37. if (can('display', 'pay_cotisation_page')) {
  38. children.push(this.constructMenu('pay_cotisation', {name: 'fa-euro-sign'}, '/cotisation/pay', true))
  39. }
  40. if (can('display', 'check_cotisation_page')) {
  41. children.push(this.constructMenu('check_cotisation', {name: 'fa-euro-sign'}, '/cotisation/check', true))
  42. }
  43. if (can('display', 'ledger_cotisation_page')) {
  44. children.push(this.constructMenu('ledger_cotisation', {name: 'fa-euro-sign'}, '/cotisation/ledger', true))
  45. }
  46. if (can('display', 'magazine_cotisation_page')) {
  47. children.push(this.constructMenu('magazine_cotisation', {name: 'fa-euro-sign'}, '/cotisation/magazine', true))
  48. }
  49. if (can('display', 'ventilated_cotisation_page')) {
  50. children.push(this.constructMenu('ventilated_cotisation', {name: 'fa-euro-sign'}, '/cotisation/ventilated', true))
  51. }
  52. if (can('display', 'pay_erase_cotisation_page')) {
  53. children.push(this.constructMenu('pay_erase_cotisation', {name: 'fa-euro-sign'}, '/cotisation/payerase', true))
  54. }
  55. if (can('display', 'resume_cotisation_page')) {
  56. children.push(this.constructMenu('resume_cotisation', {name: 'fa-euro-sign'}, '/cotisation/resume', true))
  57. }
  58. if (can('display', 'history_cotisation_page')) {
  59. children.push(this.constructMenu('history_cotisation', {name: 'fa-euro-sign'}, '/cotisation/history', true))
  60. }
  61. if (can('display', 'call_cotisation_page')) {
  62. children.push(this.constructMenu('call_cotisation', {name: 'fa-euro-sign'}, '/cotisation/call', true))
  63. }
  64. if (can('display', 'history_struture_cotisation_page')) {
  65. children.push(this.constructMenu('history_struture_cotisation', {name: 'fa-euro-sign'}, '/cotisation/historystructure', true))
  66. }
  67. if (can('display', 'insurance_cotisation_page')) {
  68. children.push(this.constructMenu('insurance_cotisation', {name: 'fa-euro-sign'}, '/cotisation/insurance', true))
  69. }
  70. if (can('display', 'resume_all_cotisation_page')) {
  71. children.push(this.constructMenu('resume_all_cotisation', {name: 'fa-euro-sign'}, '/cotisation/resumeall', true))
  72. }
  73. if (can('display', 'resume_pay_cotisation_page')) {
  74. children.push(this.constructMenu('resume_pay_cotisation', {name: 'fa-euro-sign'}, '/cotisation/resumepay', true))
  75. }
  76. if (children.length === 1) {
  77. return children[0]
  78. } else if (children.length > 0) {
  79. return this.constructMenu('cotisations', {name: 'fa-money-bill'}, undefined, undefined, children)
  80. } else {
  81. return null
  82. }
  83. }
  84. }
  85. export const getCotisationsMenu = () => new CotisationsMenu().getMenu()