websiteListMenuBuilder.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
  2. import {MenuGroup, MenuItems} from "~/types/layout";
  3. import {MENU_LINK_TYPE} from "~/types/enum/layout";
  4. import * as _ from 'lodash-es'
  5. import UrlUtils from "~/services/utils/urlUtils";
  6. /**
  7. * Menu : Liste des sites internet de la structure et de ses structures parentes
  8. */
  9. export default class WebsiteListMenuBuilder extends AbstractMenuBuilder {
  10. static readonly menuName = "WebsiteList"
  11. /**
  12. * Construit le menu Site internet, ou null si aucune page accessible
  13. */
  14. build(): MenuGroup | null {
  15. const children: MenuItems = []
  16. // Add organization website
  17. if (this.organizationProfile.website) {
  18. const url = UrlUtils.join(this.organizationProfile.website, '/typo3')
  19. children.push(this.createItem(this.organizationProfile.name as string, undefined, url, MENU_LINK_TYPE.EXTERNAL))
  20. }
  21. // Add parents websites
  22. _.each(this.organizationProfile.parents, (parent:any) => {
  23. if (parent.id && parent.name && parent.website && parent.id != this.runtimeConfig.OPENTALENT_MANAGER_ID) {
  24. children.push(this.createItem(parent.name, undefined, parent.website, MENU_LINK_TYPE.EXTERNAL))
  25. }
  26. })
  27. if (children.length > 0) {
  28. return this.createGroup('websiteList', {name: 'fas fa-globe-americas'}, children)
  29. }
  30. return null
  31. }
  32. }