websiteMenu.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import {ItemMenu, ItemsMenu, organizationState} from "~/types/types";
  2. import BaseMenu from "~/use/template/Menus/baseMenu";
  3. import * as _ from "lodash"
  4. class WebsiteMenu extends BaseMenu{
  5. private $ability:any;
  6. private $store:any;
  7. constructor($config:any, $ability:any, $store:any) {
  8. super($config)
  9. this.$ability = $ability
  10. this.$store = $store
  11. }
  12. /**
  13. * Construit le menu Site internet ou null si aucune page accessible
  14. * @return {ItemMenu | null}
  15. */
  16. getMenu():ItemMenu | null {
  17. const children:ItemsMenu = [];
  18. children.push(this.constructMenu('fa-globe-europe', this.$store.state.profile.organization.name, this.getWebsite(this.$store.state.profile.organization), false, undefined, true))
  19. if(!this.$store.state.profile.organization.website && this.$store.state.profile.access.isAdminAccess)
  20. children.push(this.constructMenu('fa-globe-europe', 'advanced_modification', this.getWebsite(this.$store.state.profile.organization) + '/typo3', false, undefined, true))
  21. _.each(this.$store.state.profile.organization.parents, parent => {
  22. children.push(this.constructMenu('fa-globe-europe', parent.name, this.getWebsite(parent), false, undefined, true))
  23. })
  24. return children.length > 0 ? this.constructMenu('fa-globe-europe', 'website', undefined, undefined, children) : null;
  25. }
  26. getWebsite(organization:organizationState):string{
  27. return organization.website ? organization.website : this.$config.baseURL_typo3.replace('###subDomain###', organization.subDomain)
  28. }
  29. }
  30. export const getWebsiteMenu = ($config:any, $ability:any, $store:any) => new WebsiteMenu($config, $ability, $store).getMenu()