| 12345678910111213141516171819202122232425262728293031323334 |
- import {ItemMenu, ItemsMenu} from "~/types/interfaces";
- import BaseMenu from "~/use/layout/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('schedule', 'fa-calendar-alt', '/calendar', true))
- }
- if (this.$ability().can('display', 'attendance_page')) {
- children.push(this.constructMenu('attendances', 'fa-calendar-check', '/attendances/list/', true))
- }
- if(children.length === 1){
- return children[0];
- }
- return children.length > 0 ? this.constructMenu('schedule', 'fa-calendar-alt', undefined, undefined, children) : null;
- }
- }
- export const getAgendaMenu = ($config:any, $ability:any) => new AgendaMenu($config, $ability).getMenu()
|