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 override readonly menuName = 'Configuration' /** * Construit le menu Header Configuration ou null si aucune page accessible */ build(): MenuItem | MenuGroup | null { const children: MenuItems = [] // 1. "Fiche de la structure" -> 'organization_page' 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, ), ) } // 2. "Préférences" -> 'parameters_page' children.push( ...this.makeChildren([ { pageName: 'parameters_page', endOfSubsection: true }, ]), ) // 3. "Enseignements" -> 'education' if (this.ability.can('display', 'education_page')) { children.push( this.createItem( 'education', undefined, '/educations/list/', MENU_LINK_TYPE.V1, ), ) } // 4. "Parcours" -> 'parcours' if (this.ability.can('display', 'parcours_page')) { children.push( this.createItem( 'parcours', undefined, '/education_curriculum_packs/list/', MENU_LINK_TYPE.V1, ), ) } // 5. "Sections" -> 'activities' if (this.ability.can('display', 'activities_page')) { children.push( this.createItem( 'activities', undefined, '/activities/list/', MENU_LINK_TYPE.V1, ), ) } // 6. "Préinscription(s) en ligne" -> 'online_registration_settings' 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, ), ) } // 7. "Dupliquer les cours hebdomadaires" -> 'course_duplication' if (this.ability.can('display', 'course_duplication_page')) { children.push( this.createItem( 'course_duplication', undefined, '/duplicate_courses', MENU_LINK_TYPE.V1, false, true, ), ) } // 8. "Facturation" -> 'billing_settings' 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, ), ) } // 9. "Liste des produits" -> 'billing_product' if (this.ability.can('display', 'billing_product_page')) { children.push( this.createItem( 'billing_product', undefined, '/intangibles/list/', MENU_LINK_TYPE.V1, ), ) } // 10. "Modèles de quotients familiaux" -> 'family_quotient_models' if (this.ability.can('display', 'family_quotient_models_page')) { children.push( this.createItem( 'family_quotient_models', undefined, '/family_quotient_models/list/', MENU_LINK_TYPE.V1, ), ) } // 11. "Echéanciers de facturation" -> 'billing_schedules' if (this.ability.can('display', 'billing_schedules_settings_page')) { children.push( this.createItem( 'billing_schedules', undefined, '/bill_schedules/list/', MENU_LINK_TYPE.V1, false, true, ), ) } // 12. "Lieux" -> 'places' if (this.ability.can('display', 'place_page')) { children.push( this.createItem( 'places', undefined, '/places/list/', MENU_LINK_TYPE.V1, ), ) } // 13. "Mails système" -> 'template_systems' if (this.ability.can('display', 'template_systems_page')) { children.push( this.createItem( 'template_systems', undefined, '/template_systems/list/', MENU_LINK_TYPE.V1, ), ) } // 14. "Pseudonymisation" -> 'pseudonymization' if (this.ability.can('display', 'pseudonymization_page')) { children.push( this.createItem( 'pseudonymization', undefined, '/pseudonymizationList/list/', MENU_LINK_TYPE.V1, ), ) } // 15. "Tags" -> 'tags' if (this.ability.can('display', 'tag_page')) { children.push( this.createItem('tags', undefined, '/taggs/list/', MENU_LINK_TYPE.V1), ) } // 16. "Importer" -> 'import' if (this.ability.can('display', 'import_page')) { children.push( this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1), ) } // CMF licence (not in the required order, but keeping it at the end) if (this.ability.can('display', 'cmf_licence_page')) { children.push( this.createItem( 'cmf_licence_generate', undefined, '/licence_cmf/organization', 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 } }