| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import * as _ from 'lodash-es'
- import AbstractMenuBuilder from '~/services/layout/menuBuilder/abstractMenuBuilder'
- import type { MenuGroup, MenuItems } from '~/types/layout'
- import { MENU_LINK_TYPE } from '~/types/enum/layout'
- import type { BaseOrganizationProfile } from '~/types/interfaces'
- /**
- * Menu : Liste des sites internet de la structure et de ses structures parentes
- */
- export default class WebsiteListMenuBuilder extends AbstractMenuBuilder {
- static override readonly menuName = 'WebsiteList'
- static OPENTALENT_MANAGER_ID = 93931
- /**
- * Construit le menu Site internet, ou null si aucune page accessible
- */
- build(): MenuGroup | null {
- const children: MenuItems = []
- // Add organization website
- if (this.organizationProfile.website) {
- children.push(
- this.createItem(
- this.organizationProfile.name as string,
- undefined,
- this.organizationProfile.website,
- MENU_LINK_TYPE.EXTERNAL,
- ),
- )
- }
- // Add parents websites
- _.each(
- this.organizationProfile.parents,
- (parent: BaseOrganizationProfile) => {
- if (
- parent.id &&
- parent.name &&
- parent.website &&
- parent.id !== WebsiteListMenuBuilder.OPENTALENT_MANAGER_ID
- ) {
- children.push(
- this.createItem(
- parent.name,
- undefined,
- parent.website,
- MENU_LINK_TYPE.EXTERNAL,
- ),
- )
- }
- },
- )
- if (children.length > 0) {
- return this.createGroup(
- 'websiteList',
- { name: 'fas fa-globe-americas' },
- children,
- )
- }
- return null
- }
- }
|