configurationMenuBuilder.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import {MenuGroup, MenuItem, MenuItems} from "~/types/layout";
  3. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  4. /**
  5. * Classe pour la construction du Menu Paramètres
  6. */
  7. export default class ConfigurationMenuBuilder extends AbstractMenuBuilder {
  8. static readonly menuName = "Configuration"
  9. /**
  10. * Construit le menu Header Configuration ou null si aucune page accessible
  11. */
  12. build (): MenuItem | MenuGroup | null {
  13. const children: MenuItems = []
  14. if (this.ability.can('display', 'organization_page')) {
  15. children.push(this.createItem('organization_page', undefined, `/organization`, MENU_LINK_TYPE.V1))
  16. }
  17. if (this.ability.can('display', 'cmf_licence_page')) {
  18. children.push(this.createItem('cmf_licence_generate', undefined, '/cmf_licence/organization', MENU_LINK_TYPE.INTERNAL))
  19. }
  20. if (this.ability.can('display', 'parameters_page')) {
  21. children.push(this.createItem('parameters', undefined,`/parameters`, MENU_LINK_TYPE.V1))
  22. }
  23. if (this.ability.can('display', 'place_page')) {
  24. children.push(this.createItem('place', undefined, '/places/list/', MENU_LINK_TYPE.V1))
  25. }
  26. if (this.ability.can('display', 'education_page')) {
  27. children.push(this.createItem('education', undefined, '/educations/list/', MENU_LINK_TYPE.V1))
  28. }
  29. if (this.ability.can('display', 'tag_page')) {
  30. children.push(this.createItem('tag', undefined, '/taggs/list/', MENU_LINK_TYPE.V1))
  31. }
  32. if (this.ability.can('display', 'activities_page')) {
  33. children.push(this.createItem('activities', undefined, '/activities/list/', MENU_LINK_TYPE.V1))
  34. }
  35. if (this.ability.can('display', 'template_systems_page')) {
  36. children.push(this.createItem('template_systems', undefined,'/template_systems/list/', MENU_LINK_TYPE.V1))
  37. }
  38. if (this.ability.can('display', 'billing_settings_page')) {
  39. children.push(this.createItem('billing_settings', undefined, '/main/edit/billing_settings/' + this.organizationProfile.id, MENU_LINK_TYPE.V1))
  40. }
  41. if (this.ability.can('display', 'online_registration_settings_page')) {
  42. children.push(this.createItem('online_registration_settings', undefined, '/main/edit/online_registration_settings/' + this.organizationProfile.id, MENU_LINK_TYPE.V1))
  43. }
  44. if (this.ability.can('display', 'transition_next_year_page')) {
  45. children.push(this.createItem('transition_next_year', undefined, '/transition_next_year', MENU_LINK_TYPE.V1))
  46. }
  47. if (this.ability.can('display', 'course_duplication_page')) {
  48. children.push(this.createItem('course_duplication', undefined, '/duplicate_courses', MENU_LINK_TYPE.V1))
  49. }
  50. if (this.ability.can('display', 'import_page')) {
  51. children.push(this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1))
  52. }
  53. if (children.length > 1) {
  54. // Plusieurs éléments, on retourne un groupe
  55. return this.createGroup('configuration', {name: 'fas fa-cogs'}, children)
  56. }
  57. else if (children.length === 1) {
  58. // Un seul élément, on retourne cet élément seul
  59. return children[0]
  60. }
  61. return null
  62. }
  63. }