| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 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 {
- /**
- * 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.constructMenuItem('person', {name: 'fa-user'}, to, true))
- }
- if (can('display', 'student_registration_page')) {
- children.push(this.constructMenuItem('family_view', {name: 'fa-users'}, '/student_registration/new', true))
- }
- if (can('display', 'education_student_next_year_page')) {
- children.push(this.constructMenuItem('education_student_next_year', {name: 'fa-list-alt'}, '/education_student_next_year/list/', true))
- }
- if (can('display', 'commissions_page')) {
- children.push(this.constructMenuItem('commissions', {name: 'fa-street-view'}, '/commissions/list/', true))
- }
- if (can('display', 'network_children_page')) {
- children.push(this.constructMenuItem('network', {name: 'fa-sitemap'}, 'networks/list/', true))
- }
- if (can('display', 'network_parents_page')) {
- children.push(this.constructMenuItem('my_network', {name: 'fa-sitemap'}, '/network_artist_schools/list/', true))
- }
- if (children.length === 1) {
- return children[0]
- } else if (children.length > 0) {
- return this.constructMenuItem('address_book', {name: 'fa-address-book'}, undefined, undefined, children)
- } else {
- return null
- }
- }
- }
- export const getAccessMenu = () => new AccessMenu().getMenu()
|