configurationMenu.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {ItemMenu, ItemsMenu} from "~/types/types";
  2. import BaseMenu from "~/use/layout/Menus/baseMenu";
  3. class ConfigurationMenu extends BaseMenu{
  4. private $ability:any;
  5. private $store:any;
  6. constructor($config:any, $ability:any, $store: any) {
  7. super($config)
  8. this.$ability = $ability
  9. this.$store = $store
  10. }
  11. /**
  12. * Construit le menu Header Configuration ou null si aucune page accessible
  13. * @return {ItemMenu | null}
  14. */
  15. getHeaderMenu():ItemMenu | null {
  16. const children:ItemsMenu = [];
  17. if (this.$ability().can('display', 'organization_page')) {
  18. children.push(this.constructMenu('organization_page', undefined,'/organization/edit'))
  19. }
  20. if (this.$ability().can('display', 'cmf_licence_page')) {
  21. children.push(this.constructMenu('cmf_licence_generate', undefined,'/attendances/list/', true))
  22. }
  23. if (this.$ability().can('display', 'parameters_page')) {
  24. children.push(this.constructMenu('parameters', undefined,'/configuration/parameters'))
  25. }
  26. if (this.$ability().can('display', 'place_page')) {
  27. children.push(this.constructMenu('place', undefined,'/places/list/', true))
  28. }
  29. if (this.$ability().can('display', 'education_page')) {
  30. children.push(this.constructMenu('education', undefined,'/educations/list/', true))
  31. }
  32. if (this.$ability().can('display', 'tag_page')) {
  33. children.push(this.constructMenu('tag', undefined,'/taggs/list/', true))
  34. }
  35. if (this.$ability().can('display', 'activities_page')) {
  36. children.push(this.constructMenu('activities', undefined,'/activities/list/', true))
  37. }
  38. if (this.$ability().can('display', 'billing_settings_page')) {
  39. children.push(this.constructMenu('billing_settings', undefined,'/billing_settings/' + this.$store.state.profile.organization.id, true))
  40. }
  41. if (this.$ability().can('display', 'online_registration_settings_page')) {
  42. children.push(this.constructMenu('online_registration_settings', undefined,'/online_registration_settings/' + this.$store.state.profile.organization.id, true))
  43. }
  44. if (this.$ability().can('display', 'transition_next_year_page')) {
  45. children.push(this.constructMenu('transition_next_year', undefined,'/attendances/list/', true))
  46. }
  47. if (this.$ability().can('display', 'course_duplication_page')) {
  48. children.push(this.constructMenu('course_duplication', undefined,'/duplicate_courses/', true))
  49. }
  50. if (this.$ability().can('display', 'import_page')) {
  51. children.push(this.constructMenu('import', undefined,'/import/all/', true))
  52. }
  53. return children.length > 0 ? this.constructMenu('configuration', 'fa-cogs', undefined, undefined, children) : null;
  54. }
  55. }
  56. export const getConfigurationMenu = ($config:any, $ability:any, $store:any) => new ConfigurationMenu($config, $ability, $store).getHeaderMenu()