accountMenuBuilder.ts 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import {MenuGroup, MenuItem, MenuItems} from '~/types/layout'
  2. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  3. import AbstractMenuBuilder from '~/services/menuBuilder/abstractMenuBuilder'
  4. /**
  5. * Menu Mon compte
  6. */
  7. export default class AccountMenuBuilder extends AbstractMenuBuilder {
  8. name() {
  9. return 'Account'
  10. }
  11. /**
  12. * Construit le menu Header Configuration ou null si aucune page accessible
  13. */
  14. build (): MenuItem | MenuGroup | null {
  15. const children: MenuItems = []
  16. if (this.ability.can('display', 'my_schedule_page')) {
  17. children.push(this.createItem('my_schedule_page', undefined, '/my_calendar', MENU_LINK_TYPE.V1))
  18. }
  19. if (this.ability.can('display', 'attendance_bookings_page')) {
  20. children.push(this.createItem('attendance_bookings_menu', undefined, '/own_attendance', MENU_LINK_TYPE.V1))
  21. }
  22. if (this.ability.can('display', 'my_attendance_page')) {
  23. children.push(this.createItem('my_attendance', undefined, '/my_attendances/list/', MENU_LINK_TYPE.V1))
  24. }
  25. if (this.ability.can('display', 'my_invitation_page')) {
  26. children.push(this.createItem('my_invitation', undefined, '/my_invitations/list/', MENU_LINK_TYPE.V1))
  27. }
  28. if (this.ability.can('display', 'my_students_page')) {
  29. children.push(this.createItem('my_students', undefined, '/my_students/list/', MENU_LINK_TYPE.V1))
  30. }
  31. if (this.ability.can('display', 'my_students_education_students_page')) {
  32. children.push(this.createItem('my_students_education_students', undefined, '/my_students_education_students/list/', MENU_LINK_TYPE.V1))
  33. }
  34. if (this.ability.can('display', 'criteria_notations_page') || this.ability.can('display', 'criteria_notations_page_from_account_menu')) {
  35. children.push(this.createItem('criteria_notations', undefined, '/criteria_notations/list/', MENU_LINK_TYPE.V1))
  36. }
  37. if (this.ability.can('display', 'my_education_students_page')) {
  38. children.push(this.createItem('my_education_students', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/my_education_students/list/`, MENU_LINK_TYPE.V1))
  39. }
  40. if (this.ability.can('display', 'send_an_email_page')) {
  41. children.push(this.createItem('send_an_email', undefined, `/list/create/emails`, MENU_LINK_TYPE.V1))
  42. }
  43. if (this.ability.can('display', 'my_documents_page')) {
  44. children.push(this.createItem('my_documents', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/show/my_access_file`, MENU_LINK_TYPE.V1))
  45. }
  46. if (this.ability.can('display', 'my_profile_page')) {
  47. children.push(this.createItem('my_profile', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard`, MENU_LINK_TYPE.V1))
  48. }
  49. if (this.ability.can('display', 'adherent_list_page')) {
  50. children.push(this.createItem('adherent_list', undefined, `/adherent_contacts/list/`, MENU_LINK_TYPE.V1))
  51. }
  52. if (this.ability.can('display', 'subscription_page')) {
  53. children.push(this.createItem('my_subscription', undefined, `/subscription`))
  54. }
  55. if (this.ability.can('display', 'my_bills_page')) {
  56. children.push(this.createItem('my_bills', undefined, `/main/my_profile/${this.accessProfile.id}/dashboard/show/my_bills`, MENU_LINK_TYPE.V1))
  57. }
  58. if (this.ability.can('display', 'cmf_licence_person_page')) {
  59. children.push(this.createItem('print_my_licence', undefined, `/licence_cmf/user`, MENU_LINK_TYPE.V1))
  60. }
  61. children.push(this.createItem('logout', undefined, `/logout`, MENU_LINK_TYPE.V1, true))
  62. const icon = {
  63. avatarId: this.accessProfile.avatarId,
  64. avatarByDefault: this.accessProfile.gender == 'MISTER' ? 'men-1.png' : 'women-1.png'
  65. }
  66. return this.createGroup('my_account', icon, children)
  67. }
  68. }