admin2iosMenuBuilder.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
  3. import { MENU_LINK_TYPE } from '~/types/enum/layout'
  4. /**
  5. * Menu Admin 2IOS
  6. */
  7. export default class Admin2iosMenuBuilder extends AbstractMenuBuilder {
  8. static readonly menuName = 'Admin2ios'
  9. /**
  10. * Construit le menu Administration 2ios ou null si aucune page accessible
  11. */
  12. build(): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'all_accesses_page')) {
  15. children.push(
  16. this.createItem(
  17. 'all_accesses',
  18. { name: 'fas fa-users' },
  19. '/all_accesses/list/',
  20. MENU_LINK_TYPE.V1,
  21. ),
  22. )
  23. }
  24. if (this.ability.can('display', 'all_organizations_page')) {
  25. children.push(
  26. this.createItem(
  27. 'all_organizations',
  28. { name: 'fas fa-building' },
  29. '/organization_params/list/',
  30. MENU_LINK_TYPE.V1,
  31. ),
  32. )
  33. }
  34. if (this.ability.can('display', 'tips_page')) {
  35. children.push(
  36. this.createItem(
  37. 'tips',
  38. { name: 'fas fa-info-circle' },
  39. '/tips/list/',
  40. MENU_LINK_TYPE.V1,
  41. ),
  42. )
  43. }
  44. if (this.ability.can('display', 'dgv_page')) {
  45. children.push(
  46. this.createItem(
  47. 'dgv',
  48. { name: 'fas fa-house-damage' },
  49. '/admin2ios/dgv',
  50. MENU_LINK_TYPE.V1,
  51. ),
  52. )
  53. }
  54. if (this.ability.can('display', 'cmf_cotisation_page')) {
  55. children.push(
  56. this.createItem(
  57. 'cmf_cotisation',
  58. { name: 'fas fa-info-circle' },
  59. '/admin2ios/cotisationcmf',
  60. MENU_LINK_TYPE.V1,
  61. ),
  62. )
  63. }
  64. if (this.ability.can('display', 'right_page')) {
  65. children.push(
  66. this.createItem(
  67. 'right_menu',
  68. { name: 'fas fa-balance-scale-right' },
  69. '/admin2ios/right',
  70. MENU_LINK_TYPE.V1,
  71. ),
  72. )
  73. }
  74. if (this.ability.can('display', 'tree_page')) {
  75. children.push(
  76. this.createItem(
  77. 'tree_menu',
  78. { name: 'fas fa-sitemap' },
  79. '/admin2ios/tree',
  80. MENU_LINK_TYPE.V1,
  81. ),
  82. )
  83. }
  84. if (children.length > 1) {
  85. // Plusieurs éléments, on retourne un groupe
  86. return this.createGroup('admin2ios', { name: 'fas fa-sitemap' }, children)
  87. } else if (children.length === 1) {
  88. // Un seul élément, on retourne cet élément seul
  89. return children[0]
  90. }
  91. return null
  92. }
  93. }