statsMenuBuilder.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import AbstractMenuBuilder from '~/services/menuBuilder/abstractMenuBuilder'
  2. import {MenuGroup, MenuItem, MenuItems} from "~/types/layout";
  3. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  4. /**
  5. * Menu Statistiques
  6. */
  7. export default class StatsMenuBuilder extends AbstractMenuBuilder {
  8. static readonly menuName = "Stats"
  9. /**
  10. * Construit le menu Statistique et Dons ou null si aucune page accessible
  11. */
  12. build(): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'report_activity_page')) {
  15. children.push(this.createItem('report_activity', {name: 'fas fa-chart-bar'}, '/report_activity', MENU_LINK_TYPE.V1))
  16. }
  17. if (this.ability.can('display', 'education_quotas_page')) {
  18. children.push(this.createItem('educations_quotas_by_education', {name: 'fas fa-user-circle'}, '/educations_quotas_by_education_year/list/', MENU_LINK_TYPE.V1))
  19. }
  20. if (this.ability.can('display', 'fede_stats_page')) {
  21. children.push(this.createItem('fede_stats', {name: 'fas fa-chart-bar'}, '/statistic/membersfedeonly', MENU_LINK_TYPE.V1))
  22. }
  23. if (this.ability.can('display', 'structure_stats_page')) {
  24. children.push(this.createItem('structure_stats', {name: 'fas fa-chart-bar'}, '/statistic/membersfedeassos', MENU_LINK_TYPE.V1))
  25. }
  26. if (children.length > 1) {
  27. // Plusieurs éléments, on retourne un groupe
  28. return this.createGroup('stats', {name: 'fas fa-chart-bar'}, children)
  29. }
  30. else if (children.length === 1) {
  31. // Un seul élément, on retourne cet élément seul
  32. return children[0]
  33. }
  34. return null
  35. }
  36. }