import {ItemMenu, ItemsMenu} from "~/types/types"; import BaseMenu from "~/use/template/Menus/baseMenu"; class AgendaMenu extends BaseMenu{ private $ability:any; constructor($config:any, $ability:any) { super($config) this.$ability = $ability } /** * Construit le menu Agenda ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu():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; } } export const getAgendaMenu = ($config:any, $ability:any) => new AgendaMenu($config, $ability).getMenu()