import { ItemMenu, ItemsMenu, Menu } from '~/types/interfaces' import { $organizationProfile } from '~/services/profile/organizationProfile' import BaseMenu from '~/composables/layout/Menus/baseMenu' import {useAbility} from "@casl/vue"; /** * @category composables/layout/Menus * @class AccessMenu * Classe pour la construction du Menu Répertoire */ class AccessMenu extends BaseMenu implements Menu { /** * @constructor * Initialisation des services issues du context */ constructor () { const {$config} = useNuxtApp() super($config) } /** * Construit le menu Répertoire, ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu (): ItemMenu | null { const children: ItemsMenu = [] const {can} = useAbility() if (can('display', 'accesses_page')) { const organization = $organizationProfile() const to = organization.isSchool() ? '/students/list/' : '/adherent/list/' children.push(this.constructMenu('person', {name: 'fa-user'}, to, true)) } if (can('display', 'student_registration_page')) { children.push(this.constructMenu('family_view', {name: 'fa-users'}, '/student_registration/new', true)) } if (can('display', 'education_student_next_year_page')) { children.push(this.constructMenu('education_student_next_year', {name: 'fa-list-alt'}, '/education_student_next_year/list/', true)) } if (can('display', 'commissions_page')) { children.push(this.constructMenu('commissions', {name: 'fa-street-view'}, '/commissions/list/', true)) } if (can('display', 'network_children_page')) { children.push(this.constructMenu('network', {name: 'fa-sitemap'}, 'networks/list/', true)) } if (can('display', 'network_parents_page')) { children.push(this.constructMenu('my_network', {name: 'fa-sitemap'}, '/network_artist_schools/list/', true)) } if (children.length === 1) { return children[0] } else if (children.length > 0) { return this.constructMenu('address_book', {name: 'fa-address-book'}, undefined, undefined, children) } else { return null } } } export const getAccessMenu = () => new AccessMenu().getMenu()