admin2iosMenu.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {ItemMenu, ItemsMenu} from "~/types/types";
  2. import BaseMenu from "~/use/template/Menus/baseMenu";
  3. class Admin2iosMenu 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 Administration 2ios 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', 'all_accesses_page')) {
  16. children.push(this.constructMenu('fa-users', 'all_accesses', '/all_accesses/list/', true))
  17. }
  18. if (this.$ability().can('display', 'all_organizations_page')) {
  19. children.push(this.constructMenu('fa-building', 'all_organizations', '/organization_params/list/', true))
  20. }
  21. if (this.$ability().can('display', 'tips_page')) {
  22. children.push(this.constructMenu('fa-info-circle', 'tips', '/tips/list/', true))
  23. }
  24. if (this.$ability().can('display', 'actions_lead_page')) {
  25. children.push(this.constructMenu('fa-comments-dollar', 'actions_lead', '/admin2ios/actions_lead', true))
  26. }
  27. if (this.$ability().can('display', 'renewall_list_page')) {
  28. children.push(this.constructMenu('fa-sync', 'renewall_list', '/admin2ios/renewalllist', true))
  29. }
  30. if (this.$ability().can('display', 'settlements_page')) {
  31. children.push(this.constructMenu('fa-euro-sign', 'settlements', '/admin2ios/settlements', true))
  32. }
  33. if (this.$ability().can('display', 'pendings_settlements_page')) {
  34. children.push(this.constructMenu('fa-euro-sign', 'pendings_settlements', '/admin2ios/pendings_settlements', true))
  35. }
  36. if (this.$ability().can('display', 'outages_notice_page')) {
  37. children.push(this.constructMenu('fa-cut', 'outages_notice', '/admin2ios/outagesnotice', true))
  38. }
  39. if (this.$ability().can('display', 'degraded_page')) {
  40. children.push(this.constructMenu('fa-users', 'degraded', '/admin2ios/degraded', true))
  41. }
  42. if (this.$ability().can('display', 'dgv_page')) {
  43. children.push(this.constructMenu('fa-house-damage', 'dgv', '/admin2ios/dgv', true))
  44. }
  45. if (this.$ability().can('display', 'cmf_cotisation_page')) {
  46. children.push(this.constructMenu('fa-info-circle', 'cmf_cotisation', '/admin2ios/cotisationcmf', true))
  47. }
  48. if (this.$ability().can('display', 'right_page')) {
  49. children.push(this.constructMenu('fa-balance-scale-right', 'right_menu', '/admin2ios/right', true))
  50. }
  51. if (this.$ability().can('display', 'tree_page')) {
  52. children.push(this.constructMenu('fa-sitemap', 'tree_menu', '/admin2ios/tree', true))
  53. }
  54. if(children.length === 1){
  55. return children[0];
  56. }
  57. return children.length > 0 ? this.constructMenu('fa-sitemap', 'admin2ios', undefined, undefined, children) : null;
  58. }
  59. }
  60. export const getAdmin2iosMenu = ($config:any, $ability:any) => new Admin2iosMenu($config, $ability).getMenu()