| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
- import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
- import { MENU_LINK_TYPE } from '~/types/enum/layout'
- /**
- * Menu Répertoire
- */
- export default class AccessMenuBuilder extends AbstractMenuBuilder {
- static override readonly menuName = 'Access'
- /**
- * Construit le menu Répertoire, ou null si aucune page accessible
- */
- build(): MenuGroup | MenuItem | null {
- const children: MenuItems = []
- if (this.ability.can('display', 'accesses_page')) {
- const to = this.organizationProfile.isSchool
- ? '/students/list/'
- : '/adherent/list/'
- children.push(
- this.createItem(
- 'person',
- { name: 'fas fa-user' },
- to,
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'student_registration_page')) {
- children.push(
- this.createItem(
- 'family_view',
- { name: 'fas fa-users' },
- '/student_registration/new',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'education_student_next_year_page')) {
- children.push(
- this.createItem(
- 'education_student_next_year',
- { name: 'fas fa-list-alt' },
- '/education_student_next_year/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'commissions_page')) {
- children.push(
- this.createItem(
- 'commissions',
- { name: 'fas fa-street-view' },
- '/commissions/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'network_children_page')) {
- children.push(
- this.createItem(
- 'network',
- { name: 'fas fa-sitemap' },
- 'networks/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'network_parents_page')) {
- children.push(
- this.createItem(
- 'my_network',
- { name: 'fas fa-sitemap' },
- '/network_artist_schools/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (children.length > 1) {
- // Plusieurs éléments, on retourne un groupe
- return this.createGroup(
- 'address_book',
- { name: 'fas fa-address-book' },
- children,
- )
- } else if (children.length === 1) {
- // Un seul élément, on retourne cet élément seul
- return children[0]
- }
- return null
- }
- }
|