Adding separate save buttons for measurements
This commit is contained in:
1 parent
5dc2f8dc9c
commit
7da787c3f8
16 files changed
+72
-114
No files matched your search
@@ -8,8 +8,5 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
<div class="caseProgressStatus">
|
||||
{{#button class='btn p-x-2' action='save' disabled=(isFinishDisabled)}}Save{{/button}}
|
||||
</div>
|
||||
{{/form}}
|
||||
</template>
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { Session } from 'meteor/session';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.caseProgress.onCreated(() => {
|
||||
@@ -11,48 +9,6 @@ Template.caseProgress.onCreated(() => {
|
||||
instance.progressText = new ReactiveVar();
|
||||
instance.isLocked = new ReactiveVar(false);
|
||||
instance.isFollowUp = new ReactiveVar(false);
|
||||
instance.path = 'viewer.studyViewer.measurements';
|
||||
instance.saveObserver = new Tracker.Dependency();
|
||||
|
||||
instance.api = {
|
||||
save() {
|
||||
// Clear signaled unsaved changes...
|
||||
const successHandler = () => {
|
||||
OHIF.ui.unsavedChanges.clear(`${instance.path}.*`);
|
||||
instance.saveObserver.changed();
|
||||
};
|
||||
|
||||
// Display the error messages
|
||||
const errorHandler = data => {
|
||||
OHIF.ui.showDialog('dialogInfo', Object.assign({ class: 'themed' }, data));
|
||||
};
|
||||
|
||||
const promise = instance.data.measurementApi.storeMeasurements();
|
||||
promise.then(successHandler).catch(errorHandler);
|
||||
OHIF.ui.showDialog('dialogLoading', {
|
||||
promise,
|
||||
text: 'Saving measurement data'
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
|
||||
instance.unsavedChangesHandler = () => {
|
||||
const isNotDisabled = !instance.$('.js-finish-case').hasClass('disabled');
|
||||
if (isNotDisabled && instance.progressPercent.get() === 100) {
|
||||
instance.api.save();
|
||||
}
|
||||
};
|
||||
|
||||
// Attach handler for unsaved changes dialog...
|
||||
OHIF.ui.unsavedChanges.attachHandler(instance.path, 'save', instance.unsavedChangesHandler);
|
||||
});
|
||||
|
||||
Template.caseProgress.onDestroyed(() => {
|
||||
const instance = Template.instance();
|
||||
// Remove unsaved changes handler after this view has been destroyed...
|
||||
OHIF.ui.unsavedChanges.removeHandler(instance.path, 'save', instance.unsavedChangesHandler);
|
||||
});
|
||||
|
||||
Template.caseProgress.onRendered(() => {
|
||||
@@ -178,16 +134,5 @@ Template.caseProgress.helpers({
|
||||
|
||||
const progressPercent = instance.progressPercent.get();
|
||||
return progressPercent === 100;
|
||||
},
|
||||
|
||||
isFinishDisabled() {
|
||||
const instance = Template.instance();
|
||||
|
||||
// Run this computation on save or every time any measurement / timepoint suffer changes
|
||||
OHIF.ui.unsavedChanges.depend();
|
||||
instance.saveObserver.depend();
|
||||
Session.get('LayoutManagerUpdated');
|
||||
|
||||
return OHIF.ui.unsavedChanges.probe('viewer.*') === 0;
|
||||
}
|
||||
});
|
||||
+1
-4
@@ -94,10 +94,7 @@ Template.measurementTableRow.events({
|
||||
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
||||
|
||||
// Notify that viewer suffered changes
|
||||
const { timepointId } = measurement;
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.deleted`);
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges('deleted');
|
||||
});
|
||||
}
|
||||
});
|
||||
+2
-5
@@ -89,9 +89,6 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
|
||||
});
|
||||
}
|
||||
|
||||
// Signal unsaved changes
|
||||
const { timepointId } = Collection.findOne(measurementData._id);
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${eventData.toolType}`);
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges(eventData.toolType);
|
||||
}
|
||||
+2
-5
@@ -35,9 +35,6 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
|
||||
// Update the measurement in the collection
|
||||
Collection.update(measurement._id, { $set: { [tool.attribute]: childMeasurement } });
|
||||
|
||||
// Signal unsaved changes
|
||||
const { timepointId } = Collection.findOne(measurementData._id);
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${eventData.toolType}`);
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges(eventData.toolType);
|
||||
}
|
||||
+2
-5
@@ -35,9 +35,6 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
|
||||
// Repaint the images on all viewports without the removed measurements
|
||||
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
||||
|
||||
// Signal unsaved changes
|
||||
const { timepointId } = Collection.findOne(measurementData._id);
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${eventData.toolType}`);
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges(eventData.toolType);
|
||||
}
|
||||
+2
-5
@@ -48,9 +48,6 @@ export default function ({ instance, eventData, tool }) {
|
||||
cornerstone.updateImage(OHIF.viewerbase.viewportUtils.getActiveViewportElement());
|
||||
});
|
||||
|
||||
// Signal unsaved changes
|
||||
const { timepointId } = Collection.findOne(measurementData._id);
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${eventData.toolType}`);
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges(eventData.toolType);
|
||||
}
|
||||
+2
-5
@@ -37,9 +37,6 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
|
||||
// Update the measurement in the collection
|
||||
Collection.update(measurementId, { $set: measurement });
|
||||
|
||||
// Signal unsaved changes
|
||||
const { timepointId } = Collection.findOne(measurementData._id);
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${eventData.toolType}`);
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges(eventData.toolType);
|
||||
}
|
||||
+2
-4
@@ -32,8 +32,6 @@ export default function({ instance, eventData, tool, toolGroupId, toolGroup }) {
|
||||
// Repaint the images on all viewports without the removed measurements
|
||||
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
||||
|
||||
// Signal unsaved changes
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${eventData.toolType}`);
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges(eventData.toolType);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Session } from 'meteor/session';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Extensible method to get the timepoint of the active viewport
|
||||
*
|
||||
* @returns {Object} - Timepoint data for the active viewport
|
||||
*/
|
||||
OHIF.measurements.getActiveTimepoint = () => {
|
||||
const activeViewportIndex = Session.get('activeViewport');
|
||||
const { studyInstanceUid } = OHIF.viewerbase.layoutManager.viewportData[activeViewportIndex];
|
||||
return OHIF.viewer.timepointApi.study(studyInstanceUid)[0];
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import './clearCornerstoneToolState';
|
||||
import './deactivateAllToolData';
|
||||
import './exportPdf';
|
||||
import './findAndRenderDisplaySet';
|
||||
import './getActiveTimepoint';
|
||||
import './getImageDataUrl';
|
||||
import './getMeasurementsGroupedByNumber';
|
||||
import './getLocationLabel';
|
||||
@@ -15,3 +16,4 @@ import './MeasurementManager';
|
||||
import './navigateOverLesions';
|
||||
import './syncMeasurementAndToolData';
|
||||
import './toggleLabelButton';
|
||||
import './triggerTimepointUnsavedChanges';
|
||||
@@ -60,10 +60,7 @@ OHIF.measurements.toggleLabelButton = options => {
|
||||
options.measurement.description = description;
|
||||
|
||||
// Notify that viewer suffered changes
|
||||
const { timepointId } = measurement;
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.renamed`);
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges('renamed');
|
||||
}
|
||||
};
|
||||
buttonView = Blaze.renderWithData(Template.measureFlow, data, document.body);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
/**
|
||||
* Extensible method to trigger unsaved changes on the active timepoint
|
||||
*
|
||||
* @param {String} subpath - The unsaved changes subpath that will come after the timepoint ID
|
||||
*/
|
||||
OHIF.measurements.triggerTimepointUnsavedChanges = (subpath='changed') => {
|
||||
const basePath = 'viewer.studyViewer.measurements';
|
||||
const activeTimepoint = OHIF.measurements.getActiveTimepoint();
|
||||
if (!activeTimepoint) return;
|
||||
const { timepointId } = activeTimepoint;
|
||||
const timepointPath = timepointId ? `.${timepointId}` : '';
|
||||
OHIF.ui.unsavedChanges.set(`${basePath}${timepointPath}.${subpath}`);
|
||||
};
|
||||
Reference in new issue
Block a user