LT-259 Adding warning for when user attempts to close the Lesion Tracker before saving measurements [INTEGRATING NEW MODULE INTO VIEWER + DOCUMENTATION]
This commit is contained in:
1 parent
849ca2d488
commit
d2095f3cb7
7 files changed
+134
-23
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { unloadHandlers } from '../../../lib/unloadHandlers.js';
|
||||
|
||||
Template.viewerMain.onCreated(() => {
|
||||
// Attach the Window resize listener
|
||||
@@ -9,6 +10,9 @@ Template.viewerMain.onCreated(() => {
|
||||
// See cineDialog instance.setResizeHandler function
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
// Add beforeUnload event handler to check for unsaved changes
|
||||
window.addEventListener('beforeunload', unloadHandlers.beforeUnload);
|
||||
|
||||
// Create the synchronizer used to update reference lines
|
||||
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.updateImageSynchronizer);
|
||||
});
|
||||
@@ -92,6 +96,9 @@ Template.viewerMain.onDestroyed(() => {
|
||||
// Remove the Window resize listener
|
||||
window.removeEventListener('resize', handleResize);
|
||||
|
||||
// Remove beforeUnload event handler...
|
||||
window.removeEventListener('beforeunload', unloadHandlers.beforeUnload);
|
||||
|
||||
// Destroy the synchronizer used to update reference lines
|
||||
OHIF.viewer.updateImageSynchronizer.destroy();
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
export const unloadHandlers = {
|
||||
beforeUnload: function(event) {
|
||||
// Check for any unsaved changes on viewer namespace...
|
||||
if (OHIF.ui.unsavedChanges.probe('viewer.*') > 0) {
|
||||
let confirmationMessage = 'You have unsaved changes!';
|
||||
event.returnValue = confirmationMessage;
|
||||
return confirmationMessage;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -166,6 +166,7 @@ Package.onUse(function(api) {
|
||||
api.addFiles('client/lib/isImage.js', 'client');
|
||||
api.addFiles('client/lib/sopClassDictionary.js', 'client');
|
||||
api.addFiles('client/lib/debugReactivity.js', 'client');
|
||||
api.addFiles('client/lib/unloadHandlers.js', 'client');
|
||||
|
||||
api.export('resizeViewportElements', 'client');
|
||||
api.export('handleResize', 'client');
|
||||
|
||||
Reference in new issue
Block a user