From 5017fd13afacad46eeb8ad9df116cd316166fbae Mon Sep 17 00:00:00 2001 From: Evren Ozkan Date: Fri, 9 Nov 2018 13:14:03 -0500 Subject: [PATCH] fix(hot-keys): Set the correct context name to enable hot keys based on the current page (#308) --- Packages/ohif-hotkeys/client/index.js | 1 - Packages/ohif-hotkeys/client/lib/index.js | 1 - Packages/ohif-hotkeys/client/lib/routes.js | 14 -------------- .../client/components/studylist/index.js | 1 + .../client/components/studylist/studylist.js | 12 ++++++++++++ .../components/viewer/viewerMain/viewerMain.js | 6 ++++++ .../standaloneViewerMain/standaloneViewerMain.js | 6 ++++++ 7 files changed, 25 insertions(+), 16 deletions(-) delete mode 100644 Packages/ohif-hotkeys/client/lib/index.js delete mode 100644 Packages/ohif-hotkeys/client/lib/routes.js create mode 100644 Packages/ohif-study-list/client/components/studylist/studylist.js diff --git a/Packages/ohif-hotkeys/client/index.js b/Packages/ohif-hotkeys/client/index.js index a3b6ff5b9..758f32245 100644 --- a/Packages/ohif-hotkeys/client/index.js +++ b/Packages/ohif-hotkeys/client/index.js @@ -1,2 +1 @@ import './components'; -import './lib'; diff --git a/Packages/ohif-hotkeys/client/lib/index.js b/Packages/ohif-hotkeys/client/lib/index.js deleted file mode 100644 index 86c73e446..000000000 --- a/Packages/ohif-hotkeys/client/lib/index.js +++ /dev/null @@ -1 +0,0 @@ -import './routes'; diff --git a/Packages/ohif-hotkeys/client/lib/routes.js b/Packages/ohif-hotkeys/client/lib/routes.js deleted file mode 100644 index b434438e9..000000000 --- a/Packages/ohif-hotkeys/client/lib/routes.js +++ /dev/null @@ -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(); -}); diff --git a/Packages/ohif-study-list/client/components/studylist/index.js b/Packages/ohif-study-list/client/components/studylist/index.js index 6cd09ef93..2249e8b6d 100644 --- a/Packages/ohif-study-list/client/components/studylist/index.js +++ b/Packages/ohif-study-list/client/components/studylist/index.js @@ -1,4 +1,5 @@ import './studylist.html'; +import './studylist.js'; import './studylist.styl'; import './studylistStudy/studylistStudy.html'; diff --git a/Packages/ohif-study-list/client/components/studylist/studylist.js b/Packages/ohif-study-list/client/components/studylist/studylist.js new file mode 100644 index 000000000..91c8579ae --- /dev/null +++ b/Packages/ohif-study-list/client/components/studylist/studylist.js @@ -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); +}); diff --git a/Packages/ohif-viewerbase/client/components/viewer/viewerMain/viewerMain.js b/Packages/ohif-viewerbase/client/components/viewer/viewerMain/viewerMain.js index 77b526867..fea90093e 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/viewerMain/viewerMain.js +++ b/Packages/ohif-viewerbase/client/components/viewer/viewerMain/viewerMain.js @@ -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); }); diff --git a/StandaloneViewer/StandaloneViewer/client/components/standaloneViewerMain/standaloneViewerMain.js b/StandaloneViewer/StandaloneViewer/client/components/standaloneViewerMain/standaloneViewerMain.js index ab8f311a9..4e0970fb5 100644 --- a/StandaloneViewer/StandaloneViewer/client/components/standaloneViewerMain/standaloneViewerMain.js +++ b/StandaloneViewer/StandaloneViewer/client/components/standaloneViewerMain/standaloneViewerMain.js @@ -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); });