websiteMenu.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import BaseMenu from '~/composables/layout/Menus/baseMenu'
  2. import { ItemMenu, ItemsMenu, Menu, organizationState } from '~/types/interfaces'
  3. import {useProfileOrganizationStore} from "~/store/profile/organization";
  4. import {useProfileAccessStore} from "~/store/profile/access";
  5. /**
  6. * @category composables/layout/Menus
  7. * @class WebsiteMenu
  8. * Classe pour la construction du Menu Sites internet
  9. */
  10. class WebsiteMenu extends BaseMenu implements Menu {
  11. /**
  12. * @constructor
  13. * Initialisation des services issues du context
  14. */
  15. constructor () {
  16. const {$config} = useNuxtApp()
  17. super($config)
  18. }
  19. /**
  20. * Construit le menu Site internet ou null si aucune page accessible
  21. * @return {ItemMenu | null}
  22. */
  23. getMenu (): ItemMenu | null {
  24. const profileOrganizationStore = useProfileOrganizationStore()
  25. const profileAccessStore = useProfileAccessStore()
  26. if (!profileOrganizationStore.website && profileAccessStore.isAdminAccess) {
  27. return this.constructMenu('advanced_modification', {name: 'fa-globe-americas'}, this.getWebsite(profileOrganizationStore) + '/typo3', false, undefined, true)
  28. }
  29. return null
  30. }
  31. /**
  32. * Construit le menu Header des Sites internet ou null si aucune page accessible
  33. * @return {ItemMenu | null}
  34. */
  35. getHeaderMenu (): ItemMenu | null {
  36. const profileOrganizationStore = useProfileOrganizationStore()
  37. const children: ItemsMenu = []
  38. children.push(this.constructMenu(profileOrganizationStore.name as string, undefined, this.getWebsite(profileOrganizationStore), false, undefined, true))
  39. useEach(profileOrganizationStore.parents, (parent:any) => {
  40. if(parent.id != process.env.OPENTALENT_MANAGER_ID){
  41. children.push(this.constructMenu(parent.name, undefined, this.getWebsite(parent), false, undefined, true))
  42. }
  43. })
  44. return children.length > 0 ? this.constructMenu('website', {name: 'fa-globe-americas'}, undefined, undefined, children) : null
  45. }
  46. getWebsite (organization: organizationState): string {
  47. return organization.website ?? '';
  48. }
  49. }
  50. export const getWebsiteMenu = () => new WebsiteMenu()