import {ItemMenu, ItemsMenu, organizationState} from "~/types/types"; import BaseMenu from "~/use/layout/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 = []; if(!this.$store.state.profile.organization.website && this.$store.state.profile.access.isAdminAccess){ children.push(this.constructMenu('fa-globe-europe', 'simple_modification', this.getWebsite(this.$store.state.profile.organization), false, undefined, true)) children.push(this.constructMenu('fa-globe-europe', 'advanced_modification', this.getWebsite(this.$store.state.profile.organization) + '/typo3', false, undefined, true)) } return children.length > 0 ? this.constructMenu('fa-globe-europe', 'website', undefined, undefined, children) : null; } /** * Construit le menu Header des Sites internet ou null si aucune page accessible * @return {ItemMenu | null} */ getHeaderMenu():ItemMenu | null { const children:ItemsMenu = []; children.push(this.constructMenu(this.$store.state.profile.organization.name, undefined, this.getWebsite(this.$store.state.profile.organization), false, undefined, true)) _.each(this.$store.state.profile.organization.parents, parent => { children.push(this.constructMenu(parent.name, undefined, this.getWebsite(parent), false)) }) return children.length > 0 ? this.constructMenu('website', 'fa-globe-europe', 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)