| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces'
- import BaseMenu from '~/composables/layout/Menus/baseMenu'
- import {useAbility} from "@casl/vue";
- /**
- * @category composables/layout/Menus
- * @class StatsMenu
- * Classe pour la construction du Menu Statistiques
- */
- class StatsMenu extends BaseMenu implements Menu {
- /**
- * @constructor
- * Initialisation des services issues du context
- */
- constructor () {
- const {$config} = useNuxtApp()
- super($config)
- }
- /**
- * Construit le menu Statistique et Dons ou null si aucune page accessible
- * @return {ItemMenu | null}
- */
- getMenu (): ItemMenu | null {
- const {can} = useAbility()
- const children: ItemsMenu = []
- if (can('display', 'report_activity_page')) {
- children.push(this.constructMenu('report_activity', {name: 'fa-chart-bar'}, '/report_activity', true))
- }
- if (can('display', 'education_quotas_page')) {
- children.push(this.constructMenu('educations_quotas_by_education', {name: 'fa-user-circle'}, '/educations_quotas_by_education_year/list/', true))
- }
- if (can('display', 'fede_stats_page')) {
- children.push(this.constructMenu('fede_stats', {name: 'fa-chart-bar'}, '/statistic/membersfedeonly', true))
- }
- if (can('display', 'structure_stats_page')) {
- children.push(this.constructMenu('structure_stats', {name: 'fa-chart-bar'}, '/statistic/membersfedeassos', true))
- }
- if (children.length === 1) {
- return children[0]
- } else if (children.length > 0) {
- return this.constructMenu('stats', {name: 'fa-chart-bar'}, undefined, undefined, children)
- } else {
- return null
- }
- }
- }
- export const getStatsMenu = () => new StatsMenu().getMenu()
|