diff --git a/config/example.json b/config/example.json index dc5cabe6c..0867dc69c 100644 --- a/config/example.json +++ b/config/example.json @@ -27,6 +27,11 @@ "labels": ["opensource"] }, "loginTimout": 600000, + "viewLink": { + "sectionPrefix": "Section ", + "appendixPrefix": "Appendix ", + "hidePrefixForSections": false + }, "experimental": [ { "id": "experimental-magic", diff --git a/src/ve-components/presentations/mms-view-link.component.ts b/src/ve-components/presentations/mms-view-link.component.ts index 556d29cdf..1baf9c23b 100644 --- a/src/ve-components/presentations/mms-view-link.component.ts +++ b/src/ve-components/presentations/mms-view-link.component.ts @@ -11,6 +11,7 @@ import { veComponents } from '@ve-components'; import { VeComponentOptions } from '@ve-types/angular'; import { ElementObject, ElementsRequest } from '@ve-types/mms'; +import {VeConfig} from "@ve-types/config"; /** * @ngdoc directive @@ -77,6 +78,7 @@ class ViewLinkController implements angular.IComponentController { private docid: string; showNum: boolean; vid: string; + private veConfig: VeConfig; constructor( private $scope: angular.IScope, @@ -88,7 +90,9 @@ class ViewLinkController implements angular.IComponentController { private viewSvc: ViewService, private applicationSvc: ApplicationService, private extensionSvc: ExtensionService - ) {} + ) { + this.veConfig = window.__env; + } $onInit(): void { this.target = this.linkTarget ? this.linkTarget : '_self'; @@ -146,7 +150,7 @@ class ViewLinkController implements angular.IComponentController { (data: ElementObject) => { this.element = data; this.elementName = data.name; - this.type = 'Section '; + this.type = this.veConfig.viewLink.sectionPrefix; this.suffix = ''; this.hash = '#' + data.id; if (this.mmsPeId && this.mmsPeId !== '') { @@ -168,6 +172,8 @@ class ViewLinkController implements angular.IComponentController { } else if (this.viewSvc.isEquation(pe)) { this.type = 'Eq. ('; this.suffix = ')'; + } else if (this.viewSvc.isSection(pe) && this.veConfig.viewLink.hidePrefixForSections) { + this.type = ''; } if (this.applicationSvc.getState().fullDoc) { this.href = `main.project.ref.view.present.document({ projectId: $ctrl.projectId, refId: $ctrl.refId, documentId: $ctrl.docid, viewId: $ctrl.vid })`; @@ -179,6 +185,15 @@ class ViewLinkController implements angular.IComponentController { this.growl.warning(`Unable to retrieve element: ${reason.message}`); } ); + } else { + if (data._veNumber) { + let numbers = data._veNumber.split('.'); + if (numbers.length > 1 && this.veConfig.viewLink.hidePrefixForSections) { + this.type = ''; + } else if (isNaN(parseInt(numbers[0]))) { + this.type = this.veConfig.viewLink.appendixPrefix; + } + } } if (this.apiSvc.isDocument(data)) { docid = data.id; diff --git a/src/ve-types/config.d.ts b/src/ve-types/config.d.ts index d9baacb4a..8ac074e2a 100644 --- a/src/ve-types/config.d.ts +++ b/src/ve-types/config.d.ts @@ -13,6 +13,11 @@ export interface VeConfig { banner?: BrandingStyle; footer?: BrandingStyle; loginTimeout?: number; + viewLink: { + sectionPrefix: string; + appendixPrefix: string; + hidePrefixForSections: boolean; + } experimental?: VeExperimentDescriptor[]; expConfig?: VeExperimentConfig; }