import {ItemMenu, ItemsMenu, organizationState} from "~/types/types"; import BaseMenu from "~/use/template/Menus/baseMenu"; import * as _ from "lodash" class WebsiteMenu extends BaseMenu{ private $ability:any; private $store:any; constructor($config:any, $ability:any, $store:any) { super($config) this.$ability = $ability this.$store = $store } /** * Construit le menu Site internet ou null si aucune page accessible * @return {ItemMenu | null} */ getMenu():ItemMenu | null { const children:ItemsMenu = []; children.push(this.constructMenu('fa-globe-europe', this.$store.state.profile.organization.name, this.getWebsite(this.$store.state.profile.organization), false, undefined, true)) if(!this.$store.state.profile.organization.website && this.$store.state.profile.access.isAdminAccess) children.push(this.constructMenu('fa-globe-europe', 'advanced_modification', this.getWebsite(this.$store.state.profile.organization) + '/typo3', false, undefined, true)) _.each(this.$store.state.profile.organization.parents, parent => { children.push(this.constructMenu('fa-globe-europe', parent.name, this.getWebsite(parent), false, undefined, true)) }) return children.length > 0 ? this.constructMenu('fa-globe-europe', 'website', undefined, undefined, children) : null; } getWebsite(organization:organizationState):string{ return organization.website ? organization.website : this.$config.baseURL_typo3.replace('###subDomain###', organization.subDomain) } } export const getWebsiteMenu = ($config:any, $ability:any, $store:any) => new WebsiteMenu($config, $ability, $store).getMenu()