configurationMenuBuilder.ts 3.1 KB

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