| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
- import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
- import { MENU_LINK_TYPE } from '~/types/enum/layout'
- /**
- * Menu Statistiques
- */
- export default class StatsMenuBuilder extends AbstractMenuBuilder {
- static override readonly menuName = 'Stats'
- /**
- * Construit le menu Statistique et Dons ou null si aucune page accessible
- */
- build(): MenuItem | MenuGroup | null {
- const children: MenuItems = []
- if (this.ability.can('display', 'report_activity_page')) {
- children.push(
- this.createItem(
- 'report_activity',
- { name: 'fas fa-chart-bar' },
- '/report_activity',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'education_quotas_page')) {
- children.push(
- this.createItem(
- 'educations_quotas_by_education',
- { name: 'fas fa-user-circle' },
- '/educations_quotas_by_education_year/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- children.push(
- this.createItem(
- 'accesses_quotas_courses_hebdos',
- { name: 'fas fa-user-circle' },
- '/accesses_quotas_courses_hebdos/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'fede_stats_page')) {
- children.push(
- this.createItem(
- 'fede_stats',
- { name: 'fas fa-chart-bar' },
- '/statistic/membersfedeonly',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (children.length > 1) {
- // Plusieurs éléments, on retourne un groupe
- return this.createGroup('stats', { name: 'fas fa-chart-bar' }, children)
- } else if (children.length === 1) {
- // Un seul élément, on retourne cet élément seul
- return children[0]
- }
- return null
- }
- }
|