| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import {ItemMenu, ItemsMenu} from "~/types/types";
- import BaseMenu from "~/use/layout/Menus/baseMenu";
- class CommunicationMenu extends BaseMenu{
- private $ability:any;
- constructor($config:any, $ability:any) {
- super($config)
- this.$ability = $ability
- }
- /**
- * Construit le menu Communication ou null si aucune page accessible
- * @return {ItemMenu | null}
- */
- getMenu():ItemMenu | null {
- const children:ItemsMenu = [];
- if (this.$ability().can('display', 'inbox_page')) {
- children.push(this.constructMenu('inbox', 'fa-inbox', '/messages/list/', true))
- }
- if (this.$ability().can('display', 'message_send_page')) {
- children.push(this.constructMenu('message_send', 'fa-paper-plane', '/messagessends/list/', true))
- }
- if (this.$ability().can('display', 'message_templates_page')) {
- children.push(this.constructMenu('message_templates', 'fa-edit', '/templates/list/', true))
- }
- if(children.length === 1){
- return children[0];
- }
- return children.length > 0 ? this.constructMenu('communication', 'fa-comments', undefined, undefined, children) : null;
- }
- }
- export const getCommunicationMenu= ($config:any, $ability:any) => new CommunicationMenu($config, $ability).getMenu()
|