configurationMenuBuilder.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import type {MenuGroup, MenuItem, MenuItems} from "~/types/layout";
  3. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  4. import UrlUtils from "~/services/utils/urlUtils";
  5. /**
  6. * Classe pour la construction du Menu Paramètres
  7. */
  8. export default class ConfigurationMenuBuilder extends AbstractMenuBuilder {
  9. static readonly menuName = "Configuration"
  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(
  17. this.createItem(
  18. 'organization_page',
  19. undefined,
  20. UrlUtils.join('/main/organizations', this.organizationProfile.id ?? '', '/dashboard'),
  21. MENU_LINK_TYPE.V1)
  22. )
  23. }
  24. if (this.ability.can('display', 'cmf_licence_page')) {
  25. children.push(this.createItem('cmf_licence_generate', undefined, '/licence_cmf/organization', MENU_LINK_TYPE.V1))
  26. }
  27. if (this.ability.can('display', 'parameters_page')) {
  28. children.push(this.createItem('parameters', undefined,`/parameters`, MENU_LINK_TYPE.INTERNAL))
  29. }
  30. if (this.ability.can('display', 'place_page')) {
  31. children.push(this.createItem('places', undefined, '/places/list/', MENU_LINK_TYPE.V1))
  32. }
  33. if (this.ability.can('display', 'education_page')) {
  34. children.push(this.createItem('education', undefined, '/educations/list/', MENU_LINK_TYPE.V1))
  35. }
  36. if (this.ability.can('display', 'tag_page')) {
  37. children.push(this.createItem('tags', undefined, '/taggs/list/', MENU_LINK_TYPE.V1))
  38. }
  39. if (this.ability.can('display', 'activities_page')) {
  40. children.push(this.createItem('activities', undefined, '/activities/list/', MENU_LINK_TYPE.V1))
  41. }
  42. if (this.ability.can('display', 'template_systems_page')) {
  43. children.push(this.createItem('template_systems', undefined,'/template_systems/list/', MENU_LINK_TYPE.V1))
  44. }
  45. if (this.ability.can('display', 'billing_settings_page')) {
  46. children.push(
  47. this.createItem(
  48. 'billing_settings',
  49. undefined,
  50. UrlUtils.join('/main/edit/billing_settings/', this.organizationProfile.id ?? ''),
  51. MENU_LINK_TYPE.V1
  52. )
  53. )
  54. }
  55. if (this.ability.can('display', 'billing_schedules_settings_page')) {
  56. children.push(
  57. this.createItem(
  58. 'billing_schedules',
  59. undefined,
  60. '/bill_schedules/list/',
  61. MENU_LINK_TYPE.V1)
  62. )
  63. }
  64. if (this.ability.can('display', 'online_registration_settings_page')) {
  65. children.push(
  66. this.createItem(
  67. 'online_registration_settings',
  68. undefined,
  69. UrlUtils.join('/main/edit/online_registration_settings/', this.organizationProfile.id ?? ''),
  70. MENU_LINK_TYPE.V1
  71. )
  72. )
  73. }
  74. if (this.ability.can('display', 'course_duplication_page')) {
  75. children.push(this.createItem('course_duplication', undefined, '/duplicate_courses', MENU_LINK_TYPE.V1))
  76. }
  77. if (this.ability.can('display', 'import_page')) {
  78. children.push(this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1))
  79. }
  80. if (children.length > 1) {
  81. // Plusieurs éléments, on retourne un groupe
  82. return this.createGroup('configuration', {name: 'fas fa-cogs'}, children)
  83. }
  84. else if (children.length === 1) {
  85. // Un seul élément, on retourne cet élément seul
  86. return children[0]
  87. }
  88. return null
  89. }
  90. }