diff --git a/config/example.json b/config/example.json index 0867dc69c..42da39f9b 100644 --- a/config/example.json +++ b/config/example.json @@ -30,7 +30,8 @@ "viewLink": { "sectionPrefix": "Section ", "appendixPrefix": "Appendix ", - "hidePrefixForSections": false + "hidePrefixForSections": false, + "alwaysKeepCurrentDoc": false }, "experimental": [ { diff --git a/src/ve-components/presentations/mms-view-link.component.ts b/src/ve-components/presentations/mms-view-link.component.ts index 1baf9c23b..6cadce1fa 100644 --- a/src/ve-components/presentations/mms-view-link.component.ts +++ b/src/ve-components/presentations/mms-view-link.component.ts @@ -12,6 +12,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"; +import {StateService} from "@uirouter/angularjs"; /** * @ngdoc directive @@ -65,6 +66,7 @@ class ViewLinkController implements angular.IComponentController { '$scope', '$element', '$compile', + '$state', 'growl', 'ElementService', 'ApiService', @@ -84,6 +86,7 @@ class ViewLinkController implements angular.IComponentController { private $scope: angular.IScope, private $element: JQuery, private $compile: angular.ICompileService, + private $state: StateService, private growl: angular.growl.IGrowlService, private elementSvc: ElementService, private apiSvc: ApiService, @@ -208,6 +211,10 @@ class ViewLinkController implements angular.IComponentController { } else { this.$element.html('view link doesn\'t refer to a view'); } + if (this.veConfig.viewLink.alwaysKeepCurrentDoc && this.applicationSvc.getState().currentDoc && + this.$state.includes('**.present.**')) { + this.docid = this.applicationSvc.getState().currentDoc; + } 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 })`; } else { diff --git a/src/ve-types/config.d.ts b/src/ve-types/config.d.ts index 8ac074e2a..0ced066db 100644 --- a/src/ve-types/config.d.ts +++ b/src/ve-types/config.d.ts @@ -17,6 +17,7 @@ export interface VeConfig { sectionPrefix: string; appendixPrefix: string; hidePrefixForSections: boolean; + alwaysKeepCurrentDoc: boolean; } experimental?: VeExperimentDescriptor[]; expConfig?: VeExperimentConfig;