import {ItemMenu, ItemsMenu} from "~/types/interfaces"; import BaseMenu from "~/use/layout/Menus/baseMenu"; class StatsMenu extends BaseMenu{ private $ability:any; constructor($config:any, $ability:any) { super($config) this.$ability = $ability } /** * Construit le menu Statistique et Dons ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu():ItemMenu | null { const children:ItemsMenu = []; if (this.$ability().can('display', 'report_activity_page')) { children.push(this.constructMenu('report_activity', 'fa-chart-bar', '/report_activity', true)) } if (this.$ability().can('display', 'fede_stats_page')) { children.push(this.constructMenu('fede_stats', 'fa-chart-bar', '/statistic/membersfedeonly', true)) } if (this.$ability().can('display', 'structure_stats_page')) { children.push(this.constructMenu('structure_stats', 'fa-chart-bar', '/statistic/membersfedeassos', true)) } if(children.length === 1){ return children[0]; } return children.length > 0 ? this.constructMenu('stats', 'fa-chart-bar', undefined, undefined, children) : null; } } export const getStatsMenu = ($config:any, $ability:any) => new StatsMenu($config, $ability).getMenu()