accountMenuBuilder.ts 3.6 KB

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