| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import {ref, useContext} from "@nuxtjs/composition-api";
- import {ItemMenu, ItemsMenu} from "~/types/types";
- import {organizationProfile} from "~/services/profile/organizationProfile";
- export default class Menu{
- private $ability:any;
- private $config:any;
- private $store:any;
- constructor() {
- const {$ability, $config, store} = useContext();
- this.$ability = $ability;
- this.$config = $config;
- this.$store = store;
- }
- useMenuConstruct(){
- let menu:ItemsMenu = [ this.constructMenu('fa-home', 'welcome', '/dashboard', true) ]
- const accessMenu = this.accessMenu()
- if(accessMenu) menu.push(accessMenu)
- const agendaMenu = this.agendaMenu()
- if(agendaMenu) menu.push(agendaMenu)
- const equipmentMenu = this.equipmentMenu()
- if(equipmentMenu) menu.push(equipmentMenu)
- const educationalMenu = this.educationalMenu()
- if(educationalMenu) menu.push(educationalMenu)
- return ref(menu)
- }
- /**
- * Menu Répertoire
- */
- accessMenu():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('fa-user', 'person', to, true))
- }
- if (this.$ability().can('display', 'student_registration_page')) {
- children.push(this.constructMenu('fa-users', 'family_view', '/student_registration/new', true))
- }
- if (this.$ability().can('display', 'education_student_next_year_page')) {
- children.push(this.constructMenu('fa-list-alt', 'education_student_next_year', '/education_student_next_year/list/', true))
- }
- if (this.$ability().can('display', 'commissions_page')) {
- children.push(this.constructMenu('fa-street-view', 'commissions', '/commissions/list/', true))
- }
- if (this.$ability().can('display', 'network_children_page')) {
- children.push(this.constructMenu('fa-sitemap', 'network', 'networks/list/', true))
- }
- if (this.$ability().can('display', 'network_parents_page')) {
- children.push(this.constructMenu('fa-sitemap', 'my_network', '/network_artist_schools/list/', true))
- }
- if(children.length === 1){
- return children[0];
- }
- return children.length > 0 ? this.constructMenu('fa-address-book', 'address_book', undefined, undefined, children) : null;
- }
- /**
- * Menu agenda
- */
- agendaMenu():ItemMenu | null {
- const children:ItemsMenu = [];
- if (this.$ability().can('display', 'agenda_page')) {
- children.push(this.constructMenu('fa-calendar-alt', 'schedule', '/calendar', true))
- }
- if (this.$ability().can('display', 'attendance_page')) {
- children.push(this.constructMenu('fa-calendar-check', 'attendances', '/attendances/list/', true))
- }
- if(children.length === 1){
- return children[0];
- }
- return children.length > 0 ? this.constructMenu('fa-calendar-alt', 'schedule', undefined, undefined, children) : null;
- }
- /**
- * Menu equipment
- */
- equipmentMenu():ItemMenu | null {
- return this.constructMenu('fa-cube', 'equipment', '/equipment/list', true)
- }
- /**
- * Menu suivi pédagogique
- */
- educationalMenu():ItemMenu | null {
- const children:ItemsMenu = [];
- if (this.$ability().can('display', 'criteria_notations_page')) {
- children.push(this.constructMenu('fa-bars', 'criteria_notations', '/criteria_notations/list/', true))
- }
- if (this.$ability().can('display', 'seizure_period_page')) {
- children.push(this.constructMenu('fa-calendar-alt', 'seizure_period', '/education_teachers/list/', true))
- }
- if (this.$ability().can('display', 'test_seizure_page')) {
- children.push(this.constructMenu('fa-pencil-alt', 'test_seizure', '/education_input/list/', true))
- }
- if (this.$ability().can('display', 'test_validation_page')) {
- children.push(this.constructMenu('fa-check', 'test_validation', '/education_notations/list/', true))
- }
- if (this.$ability().can('display', 'examen_results_page')) {
- children.push(this.constructMenu('fa-graduation-cap', 'examen_results', '/examen_convocations/list/', true))
- }
- if (this.$ability().can('display', 'education_by_student_validation_page')) {
- children.push(this.constructMenu('fa-check-square', 'education_by_student_validation', '/education_by_student/list/', true))
- }
- if(children.length === 1){
- return children[0];
- }
- return children.length > 0 ? this.constructMenu('fa-graduation-cap', 'education_state', undefined, undefined, children) : null;
- }
- /**
- * Construit un ItemMenu
- * @param icon
- * @param title
- * @param link
- * @param isOldLink
- * @param children
- */
- constructMenu(icon: string, title: string, link?: string, isOldLink?: boolean, children?: Array<ItemMenu>): ItemMenu{
- return children ? {
- icon: icon,
- title: title,
- children: children,
- } : {
- icon: icon,
- title: title,
- to: `${isOldLink ? this.$config.baseURL_adminLegacy : ''}${link}`,
- old: isOldLink,
- }
- }
- }
|