fix(hot-keys): Set the correct context name to enable hot keys based on the current page (#308)

This commit is contained in:
Evren Ozkan 2018-11-09 13:14:03 -05:00
parent 99041bebde
commit 5017fd13af
7 changed files with 25 additions and 16 deletions

View File

@ -1,2 +1 @@
import './components';
import './lib';

View File

@ -1 +0,0 @@
import './routes';

View File

@ -1,14 +0,0 @@
import { Router } from 'meteor/clinical:router';
import { Session } from 'meteor/session';
import { hotkeys } from 'meteor/ohif:hotkeys';
Router.onBeforeAction(function() {
const lastRoute = Session.get('lastRoute');
const currentRoute = this.router.current().route.getName();
if (currentRoute !== lastRoute) {
hotkeys.switchToContext(null);
Session.set('lastRoute', currentRoute);
}
this.next();
});

View File

@ -1,4 +1,5 @@
import './studylist.html';
import './studylist.js';
import './studylist.styl';
import './studylistStudy/studylistStudy.html';

View File

@ -0,0 +1,12 @@
import { Template } from 'meteor/templating';
import { OHIF } from 'meteor/ohif:core';
Template.studylist.onCreated(() => {
// Set the current context
OHIF.context.set('studylist');
});
Template.studylist.onDestroyed(() => {
// Reset the current context
OHIF.context.set(null);
});

View File

@ -28,6 +28,9 @@ Template.viewerMain.onCreated(() => {
// Add beforeUnload event handler to check for unsaved changes
window.addEventListener('beforeunload', unloadHandlers.beforeUnload);
// Set the current context
OHIF.context.set('viewer');
});
Template.viewerMain.onRendered(() => {
@ -82,4 +85,7 @@ Template.viewerMain.onDestroyed(() => {
// @TypeSafeStudies
// Clears OHIF.viewer.StudyMetadataList collection
OHIF.viewer.StudyMetadataList.removeAll();
// Reset the current context
OHIF.context.set(null);
});

View File

@ -18,6 +18,9 @@ Template.standaloneViewerMain.onCreated(() => {
// Metadata configuration
const metadataProvider = OHIF.viewer.metadataProvider;
cornerstone.metaData.addProvider(metadataProvider.provider.bind(metadataProvider));
// Set the current context
OHIF.context.set('viewer');
});
Template.standaloneViewerMain.onRendered(() => {
@ -58,4 +61,7 @@ Template.standaloneViewerMain.onDestroyed(() => {
// Clear references to all stacks in the StackManager
OHIF.viewerbase.stackManager.clearStacks();
// Reset the current context
OHIF.context.set(null);
});