| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
- import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
- import { MENU_LINK_TYPE } from '~/types/enum/layout'
- /**
- * Menu Communication
- */
- export default class CommunicationMenuBuilder extends AbstractMenuBuilder {
- static override readonly menuName = 'Communication'
- /**
- * Construit le menu Communication ou null si aucune page accessible
- */
- build(): MenuItem | MenuGroup | null {
- const children: MenuItems = []
- if (this.ability.can('display', 'inbox_page')) {
- children.push(
- this.createItem(
- 'inbox',
- { name: 'fas fa-inbox' },
- '/messages/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'message_send_page')) {
- children.push(
- this.createItem(
- 'message_send',
- { name: 'fas fa-paper-plane' },
- '/messagessends/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'message_templates_page')) {
- children.push(
- this.createItem(
- 'message_templates',
- { name: 'fas fa-edit' },
- '/templates/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (children.length > 1) {
- // Plusieurs éléments, on retourne un groupe
- return this.createGroup(
- 'communication',
- { name: 'fas fa-comments' },
- children,
- )
- } else if (children.length === 1) {
- // Un seul élément, on retourne cet élément seul
- return children[0]
- }
- return null
- }
- }
|