import {ItemMenu, ItemsMenu} from "~/types/types"; import {$organizationProfile} from "~/services/profile/organizationProfile"; import BaseMenu from "~/use/layout/Menus/baseMenu"; class AccessMenu extends BaseMenu{ private $ability:any; private $store:any; constructor($config:any, $ability:any, $store:any) { super($config) this.$ability = $ability this.$store = $store } /** * Construit le menu Répertoire ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu():ItemMenu | null { const children:ItemsMenu = []; if (this.$ability().can('display', 'accesses_page')) { const organization = $organizationProfile(this.$store) let to = organization.isSchool() ? `/students/list/` : `/adherent/list/` children.push(this.constructMenu('person', 'fa-user', to, true)) } if (this.$ability().can('display', 'student_registration_page')) { children.push(this.constructMenu('family_view', 'fa-users', '/student_registration/new', true)) } if (this.$ability().can('display', 'education_student_next_year_page')) { children.push(this.constructMenu('education_student_next_year', 'fa-list-alt', '/education_student_next_year/list/', true)) } if (this.$ability().can('display', 'commissions_page')) { children.push(this.constructMenu('commissions', 'fa-street-view', '/commissions/list/', true)) } if (this.$ability().can('display', 'network_children_page')) { children.push(this.constructMenu('network', 'fa-sitemap', 'networks/list/', true)) } if (this.$ability().can('display', 'network_parents_page')) { children.push(this.constructMenu('my_network', 'fa-sitemap', '/network_artist_schools/list/', true)) } if(children.length === 1){ return children[0]; } return children.length > 0 ? this.constructMenu('address_book', 'fa-address-book', undefined, undefined, children) : null; } } export const getAccessMenu = ($config:any, $ability:any, $store:any) => new AccessMenu($config, $ability, $store).getMenu()