Improving "Add/Edit Description" workflow

This commit is contained in:
Bruno Alves de Faria committed 2018-03-07 08:25:59 -03:00
1 parent d486ebd551
commit 3bd44fd7bc
12 files changed
+69 -19

No files matched your search

@@ -76,6 +76,11 @@ export default function ({ instance, eventData, tool, toolGroupId, toolGroup })
measurement.location = relatedTimepoint.location;
}
// Use the related timepoint description if found and defined
if (relatedTimepoint && relatedTimepoint.description) {
measurement.description = relatedTimepoint.description;
}
// Clean the measurement according to the Schema
Collection._c2._simpleSchema.clean(measurement);
@@ -36,6 +36,11 @@ export default function ({ instance, eventData, tool }) {
measurement.location = relatedTimepoint.location;
}
// Use the related timepoint description if found and defined
if (relatedTimepoint && relatedTimepoint.description) {
measurement.description = relatedTimepoint.description;
}
// Clean the measurement according to the Schema
Collection._c2._simpleSchema.clean(measurement);
@@ -14,7 +14,8 @@ function activateTool(measurementData) {
const imageId = OHIF.viewerbase.getImageIdForImagePath(measurementData.imagePath);
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
const toolData = toolState[imageId][toolType];
const imageToolState = toolState[imageId];
const toolData = imageToolState && imageToolState[toolType];
if (!toolData || !toolData.data || !toolData.data.length) {
return;
}
@@ -2,8 +2,6 @@ import { OHIF } from 'meteor/ohif:core';
import { $ } from 'meteor/jquery';
import { cornerstone, cornerstoneMath, cornerstoneTools } from 'meteor/ohif:cornerstone';
window.resolve = [];
OHIF.measurements.getImageDataUrl = ({
imageType='image/jpeg',
quality=1,
@@ -24,7 +22,6 @@ OHIF.measurements.getImageDataUrl = ({
}
return new Promise((resolve, reject) => {
window.resolve.push(resolve);
const loadMethod = cacheImage ? 'loadAndCacheImage' : 'loadImage';
cornerstone[loadMethod](imageId).then(image => {
// Create a cornerstone enabled element to handle the image
@@ -0,0 +1,15 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Return the parent tool data if it's a child tool or the tool data itself if not
*
* @param measurementData measurement data that must contain the toolType and measurement's _id
* @returns {Object} Parent measurement data
*/
OHIF.measurements.getParentToolData = measurementData => {
const { toolType, _id } = measurementData;
const { tool } = OHIF.measurements.getToolConfiguration(toolType);
const parentToolType = tool.parentTool || toolType;
const parentToolData = OHIF.viewer.measurementApi.tools[parentToolType].findOne(_id);
return parentToolData;
};
@@ -8,6 +8,7 @@ import './getActiveTimepoint';
import './getImageDataUrl';
import './getMeasurementsGroupedByNumber';
import './getLocationLabel';
import './getParentToolData';
import './getTimepointName';
import './getToolConfiguration';
import './hangingProtocolCustomizations';
@@ -19,3 +20,4 @@ import './saveMeasurements';
import './syncMeasurementAndToolData';
import './toggleLabelButton';
import './triggerTimepointUnsavedChanges';
import './updateMeasurementsDescription';
@@ -60,7 +60,7 @@ OHIF.measurements.toggleLabelButton = options => {
options.measurement.description = description;
// Notify that viewer suffered changes
OHIF.measurements.triggerTimepointUnsavedChanges('renamed');
OHIF.measurements.triggerTimepointUnsavedChanges('relabel');
}
};
buttonView = Blaze.renderWithData(Template.measureFlow, data, document.body);
@@ -0,0 +1,23 @@
import { OHIF } from 'meteor/ohif:core';
/**
* Updates the measurements' description for a measurement number across all timepoints
*
* @param measurementData base measurement data that must contain toolType and measurementNumber
* @param description measurement description that will be used
*/
OHIF.measurements.updateMeasurementsDescription = (measurementData, description) => {
const { toolType, measurementNumber } = measurementData;
measurementData.description = description;
const filter = { measurementNumber };
const operator = { $set: { description } };
const options = { multi: true };
const { toolGroup } = OHIF.measurements.getToolConfiguration(toolType);
toolGroup.childTools.forEach(childTool => {
const collection = OHIF.viewer.measurementApi.tools[childTool.id];
collection.update(filter, operator, options);
});
// Notify that viewer suffered changes
OHIF.measurements.triggerTimepointUnsavedChanges('relabel');
};