| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
- import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
- import { MENU_LINK_TYPE } from '~/types/enum/layout'
- /**
- * Menu Admin 2IOS
- */
- export default class Admin2iosMenuBuilder extends AbstractMenuBuilder {
- static readonly menuName = 'Admin2ios'
- /**
- * Construit le menu Administration 2ios ou null si aucune page accessible
- */
- build(): MenuItem | MenuGroup | null {
- const children: MenuItems = []
- if (this.ability.can('display', 'all_accesses_page')) {
- children.push(
- this.createItem(
- 'all_accesses',
- { name: 'fas fa-users' },
- '/all_accesses/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'all_organizations_page')) {
- children.push(
- this.createItem(
- 'all_organizations',
- { name: 'fas fa-building' },
- '/organization_params/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'tips_page')) {
- children.push(
- this.createItem(
- 'tips',
- { name: 'fas fa-info-circle' },
- '/tips/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'dgv_page')) {
- children.push(
- this.createItem(
- 'dgv',
- { name: 'fas fa-house-damage' },
- '/admin2ios/dgv',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'cmf_cotisation_page')) {
- children.push(
- this.createItem(
- 'cmf_cotisation',
- { name: 'fas fa-info-circle' },
- '/admin2ios/cotisationcmf',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'right_page')) {
- children.push(
- this.createItem(
- 'right_menu',
- { name: 'fas fa-balance-scale-right' },
- '/admin2ios/right',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'tree_page')) {
- children.push(
- this.createItem(
- 'tree_menu',
- { name: 'fas fa-sitemap' },
- '/admin2ios/tree',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (children.length > 1) {
- // Plusieurs éléments, on retourne un groupe
- return this.createGroup('admin2ios', { name: 'fas fa-sitemap' }, children)
- } else if (children.length === 1) {
- // Un seul élément, on retourne cet élément seul
- return children[0]
- }
- return null
- }
- }
|