Skip to content

Commit

Permalink
keep view links within current doc option
Browse files Browse the repository at this point in the history
  • Loading branch information
Doris Lam committed Apr 24, 2024
1 parent 23f3f09 commit 79195f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"viewLink": {
"sectionPrefix": "Section ",
"appendixPrefix": "Appendix ",
"hidePrefixForSections": false
"hidePrefixForSections": false,
"alwaysKeepCurrentDoc": false
},
"experimental": [
{
Expand Down
7 changes: 7 additions & 0 deletions src/ve-components/presentations/mms-view-link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,6 +66,7 @@ class ViewLinkController implements angular.IComponentController {
'$scope',
'$element',
'$compile',
'$state',
'growl',
'ElementService',
'ApiService',
Expand All @@ -84,6 +86,7 @@ class ViewLinkController implements angular.IComponentController {
private $scope: angular.IScope,
private $element: JQuery<HTMLElement>,
private $compile: angular.ICompileService,
private $state: StateService,
private growl: angular.growl.IGrowlService,
private elementSvc: ElementService,
private apiSvc: ApiService,
Expand Down Expand Up @@ -208,6 +211,10 @@ class ViewLinkController implements angular.IComponentController {
} else {
this.$element.html('<span class="ve-error">view link doesn\'t refer to a view</span>');
}
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 {
Expand Down
1 change: 1 addition & 0 deletions src/ve-types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface VeConfig {
sectionPrefix: string;
appendixPrefix: string;
hidePrefixForSections: boolean;
alwaysKeepCurrentDoc: boolean;
}
experimental?: VeExperimentDescriptor[];
expConfig?: VeExperimentConfig;
Expand Down

0 comments on commit 79195f2

Please sign in to comment.