| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import {ItemMenu, ItemsMenu, Menu} from "~/types/interfaces";
- import BaseMenu from "~/use/layout/Menus/baseMenu";
- import {NuxtConfig} from "@nuxt/types/config";
- import {Ability} from "@casl/ability";
- /**
- * @category Use/layout/Menus
- * @class StatsMenu
- * Classe pour la construction du Menu Statistiques
- */
- class StatsMenu extends BaseMenu implements Menu{
- private $ability:Ability;
- /**
- * @constructor
- * Initialisation des services issues du context
- */
- constructor($config:NuxtConfig, $ability:Ability) {
- 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:NuxtConfig, $ability:Ability) => new StatsMenu($config, $ability).getMenu()
|