cotisationsMenu.ts 3.8 KB

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