| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
- import type { MenuGroup, MenuItem, MenuItems } from '~/types/layout'
- import { MENU_LINK_TYPE } from '~/types/enum/layout'
- import UrlUtils from '~/services/utils/urlUtils'
- /**
- * Classe pour la construction du Menu Paramètres
- */
- export default class ConfigurationMenuBuilder extends AbstractMenuBuilder {
- static readonly menuName = 'Configuration'
- /**
- * Construit le menu Header Configuration ou null si aucune page accessible
- */
- build(): MenuItem | MenuGroup | null {
- const children: MenuItems = []
- if (this.ability.can('display', 'organization_page')) {
- children.push(
- this.createItem(
- 'organization_page',
- undefined,
- UrlUtils.join(
- '/main/organizations',
- this.organizationProfile.id ?? '',
- '/dashboard',
- ),
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- // if (this.ability.can('display', 'cmf_licence_page')) {
- // children.push(
- // this.createItem(
- // 'cmf_licence_generate',
- // undefined,
- // '/cmf_licence_structure',
- // MENU_LINK_TYPE.INTERNAL,
- // ),
- // )
- // }
- if (this.ability.can('display', 'cmf_licence_page')) {
- children.push(
- this.createItem(
- 'cmf_licence_generate',
- undefined,
- '/licence_cmf/organization',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- // if (this.ability.can('display', 'parameters_page')) {
- // children.push(
- // this.createItem(
- // 'parameters',
- // undefined,
- // `/parameters`,
- // MENU_LINK_TYPE.INTERNAL,
- // ),
- // )
- // }
- if (this.ability.can('display', 'parameters_page')) {
- children.push(
- this.createItem(
- 'parameters',
- undefined,
- `/main/edit/parameters/${this.organizationProfile.id}`,
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'place_page')) {
- children.push(
- this.createItem(
- 'places',
- undefined,
- '/places/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'education_page')) {
- children.push(
- this.createItem(
- 'education',
- undefined,
- '/educations/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'tag_page')) {
- children.push(
- this.createItem('tags', undefined, '/taggs/list/', MENU_LINK_TYPE.V1),
- )
- }
- if (this.ability.can('display', 'activities_page')) {
- children.push(
- this.createItem(
- 'activities',
- undefined,
- '/activities/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'template_systems_page')) {
- children.push(
- this.createItem(
- 'template_systems',
- undefined,
- '/template_systems/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'billing_settings_page')) {
- children.push(
- this.createItem(
- 'billing_settings',
- undefined,
- UrlUtils.join(
- '/main/edit/billing_settings/',
- this.organizationProfile.id ?? '',
- ),
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'billing_schedules_settings_page')) {
- children.push(
- this.createItem(
- 'billing_schedules',
- undefined,
- '/bill_schedules/list/',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'online_registration_settings_page')) {
- children.push(
- this.createItem(
- 'online_registration_settings',
- undefined,
- UrlUtils.join(
- '/main/edit/online_registration_settings/',
- this.organizationProfile.id ?? '',
- ),
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'course_duplication_page')) {
- children.push(
- this.createItem(
- 'course_duplication',
- undefined,
- '/duplicate_courses',
- MENU_LINK_TYPE.V1,
- ),
- )
- }
- if (this.ability.can('display', 'import_page')) {
- children.push(
- this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1),
- )
- }
- if (children.length > 1) {
- // Plusieurs éléments, on retourne un groupe
- return this.createGroup(
- 'configuration',
- { name: 'fas fa-cogs' },
- children,
- )
- } else if (children.length === 1) {
- // Un seul élément, on retourne cet élément seul
- return children[0]
- }
- return null
- }
- }
|