statsMenu.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {ItemMenu, ItemsMenu} from "~/types/types";
  2. import BaseMenu from "~/use/layout/Menus/baseMenu";
  3. class StatsMenu 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 Statistique et Dons 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', 'report_activity_page')) {
  16. children.push(this.constructMenu('report_activity', 'fa-chart-bar', '/report_activity', true))
  17. }
  18. if (this.$ability().can('display', 'fede_stats_page')) {
  19. children.push(this.constructMenu('fede_stats', 'fa-chart-bar', '/statistic/membersfedeonly', true))
  20. }
  21. if (this.$ability().can('display', 'structure_stats_page')) {
  22. children.push(this.constructMenu('structure_stats', 'fa-chart-bar', '/statistic/membersfedeassos', true))
  23. }
  24. if(children.length === 1){
  25. return children[0];
  26. }
  27. return children.length > 0 ? this.constructMenu('stats', 'fa-chart-bar', undefined, undefined, children) : null;
  28. }
  29. }
  30. export const getStatsMenu = ($config:any, $ability:any) => new StatsMenu($config, $ability).getMenu()