| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import {$organizationProfile} from '~/services/profile/organizationProfile'
- import AbstractMenuBuilder from '~/services/menuBuilder/abstractMenuBuilder'
- import {MenuGroup, MenuItem, MenuItems} from "~/types/layout";
- import {MENU_LINK_TYPE} from "~/types/enum/layout";
- /**
- * Menu Répertoire
- */
- export default class AccessMenuBuilder extends AbstractMenuBuilder {
- name() {
- return '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 organization = $organizationProfile()
- const to = organization.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
- }
- }
|