configurationMenuBuilder.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. 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(
  29. this.createItem(
  30. 'parameters',
  31. undefined,
  32. UrlUtils.join('/main/edit/parameters', this.organizationProfile.id ?? ''),
  33. MENU_LINK_TYPE.V1
  34. )
  35. )
  36. }
  37. if (this.ability.can('display', 'place_page')) {
  38. children.push(this.createItem('place', undefined, '/places/list/', MENU_LINK_TYPE.V1))
  39. }
  40. if (this.ability.can('display', 'education_page')) {
  41. children.push(this.createItem('education', undefined, '/educations/list/', MENU_LINK_TYPE.V1))
  42. }
  43. if (this.ability.can('display', 'tag_page')) {
  44. children.push(this.createItem('tag', undefined, '/taggs/list/', MENU_LINK_TYPE.V1))
  45. }
  46. if (this.ability.can('display', 'activities_page')) {
  47. children.push(this.createItem('activities', undefined, '/activities/list/', MENU_LINK_TYPE.V1))
  48. }
  49. if (this.ability.can('display', 'template_systems_page')) {
  50. children.push(this.createItem('template_systems', undefined,'/template_systems/list/', MENU_LINK_TYPE.V1))
  51. }
  52. if (this.ability.can('display', 'billing_settings_page')) {
  53. children.push(
  54. this.createItem(
  55. 'billing_settings',
  56. undefined,
  57. UrlUtils.join('/main/edit/billing_settings/', this.organizationProfile.id ?? ''),
  58. MENU_LINK_TYPE.V1
  59. )
  60. )
  61. }
  62. if (this.ability.can('display', 'billing_schedules_settings_page')) {
  63. children.push(
  64. this.createItem(
  65. 'billing_schedules',
  66. undefined,
  67. '/bill_schedules/list/',
  68. MENU_LINK_TYPE.V1)
  69. )
  70. }
  71. if (this.ability.can('display', 'online_registration_settings_page')) {
  72. children.push(
  73. this.createItem(
  74. 'online_registration_settings',
  75. undefined,
  76. UrlUtils.join('/main/edit/online_registration_settings/', this.organizationProfile.id ?? ''),
  77. MENU_LINK_TYPE.V1
  78. )
  79. )
  80. }
  81. if (this.ability.can('display', 'course_duplication_page')) {
  82. children.push(this.createItem('course_duplication', undefined, '/duplicate_courses', MENU_LINK_TYPE.V1))
  83. }
  84. if (this.ability.can('display', 'import_page')) {
  85. children.push(this.createItem('import', undefined, '/import/all', MENU_LINK_TYPE.V1))
  86. }
  87. if (children.length > 1) {
  88. // Plusieurs éléments, on retourne un groupe
  89. return this.createGroup('configuration', {name: 'fas fa-cogs'}, children)
  90. }
  91. else if (children.length === 1) {
  92. // Un seul élément, on retourne cet élément seul
  93. return children[0]
  94. }
  95. return null
  96. }
  97. }