2016-10-20 19:43:39 +02:00
|
|
|
import { Template } from 'meteor/templating';
|
|
|
|
|
import { Blaze } from 'meteor/blaze';
|
2016-11-09 11:17:51 +01:00
|
|
|
import { _ } from 'meteor/underscore';
|
2016-10-20 19:43:39 +02:00
|
|
|
import { OHIF } from 'meteor/ohif:core';
|
|
|
|
|
|
2016-11-02 13:43:46 +01:00
|
|
|
const toolMap = {
|
2016-11-11 11:56:57 +01:00
|
|
|
bidirectional: 'targets',
|
|
|
|
|
crTool: 'targets',
|
|
|
|
|
unTool: 'targets',
|
|
|
|
|
exTool: 'targets'
|
2016-11-02 13:43:46 +01:00
|
|
|
};
|
|
|
|
|
|
2016-10-20 19:43:39 +02:00
|
|
|
OHIF.measurements.toggleLabelButton = options => {
|
|
|
|
|
const removeButtonView = () => {
|
2016-11-02 13:43:46 +01:00
|
|
|
if (!options.instance.buttonView) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 19:43:39 +02:00
|
|
|
Blaze.remove(options.instance.buttonView);
|
|
|
|
|
options.instance.buttonView = null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (options.instance.buttonView) {
|
|
|
|
|
removeButtonView();
|
|
|
|
|
}
|
2016-11-02 13:43:46 +01:00
|
|
|
|
2016-11-10 18:33:42 +01:00
|
|
|
const tool = options.measurementTypeId || toolMap[options.toolType];
|
2016-11-06 12:58:59 +01:00
|
|
|
const toolCollection = options.measurementApi[tool];
|
2016-11-10 18:33:42 +01:00
|
|
|
const measurement = toolCollection.findOne(options.measurementId);
|
2016-11-06 12:58:59 +01:00
|
|
|
|
2016-11-02 13:43:46 +01:00
|
|
|
const data = {
|
2016-11-06 12:58:59 +01:00
|
|
|
measurement,
|
2016-11-02 13:43:46 +01:00
|
|
|
position: options.position,
|
|
|
|
|
threeColumns: true,
|
|
|
|
|
hideCommon: true,
|
2016-11-10 18:33:42 +01:00
|
|
|
autoClick: options.autoClick,
|
2016-11-10 18:51:34 +01:00
|
|
|
doneCallback: removeButtonView,
|
|
|
|
|
updateCallback(location, description) {
|
2016-11-10 10:14:52 +01:00
|
|
|
toolCollection.update({
|
|
|
|
|
measurementNumber: measurement.measurementNumber,
|
|
|
|
|
toolType: measurement.toolType,
|
|
|
|
|
patientId: measurement.patientId
|
|
|
|
|
}, {
|
2016-11-02 13:43:46 +01:00
|
|
|
$set: {
|
|
|
|
|
location,
|
|
|
|
|
description
|
|
|
|
|
}
|
2016-11-10 18:33:42 +01:00
|
|
|
}, {
|
|
|
|
|
multi: true
|
2016-11-02 13:43:46 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const view = Blaze.renderWithData(Template.measureFlow, data, options.element);
|
|
|
|
|
options.instance.buttonView = view;
|
2016-10-20 19:43:39 +02:00
|
|
|
};
|