Move decrementing to server and out of observe hook

This commit is contained in:
Erik Ziegler 2016-01-11 19:47:19 +01:00
parent fdde2f9ff9
commit 906f7c6234
2 changed files with 27 additions and 34 deletions

View File

@ -181,13 +181,6 @@ Template.viewer.onCreated(function() {
removeToolDataWithMeasurementId(imageId, toolType, measurementId); removeToolDataWithMeasurementId(imageId, toolType, measurementId);
}); });
// Update all Measurements to decrement the lesion numbers for those
// that were created after the current lesion by 1
Meteor.call('decrementLesionNumbers', data, function(error, response) {
if (error) {
log.warn(error);
}
// Sync database data with toolData for all the measurements // Sync database data with toolData for all the measurements
// that have just been updated // that have just been updated
@ -209,7 +202,6 @@ Template.viewer.onCreated(function() {
viewports.each(function(index, element) { viewports.each(function(index, element) {
cornerstone.updateImage(element); cornerstone.updateImage(element);
}); });
});
} }
}); });
} }

View File

@ -1,13 +1,7 @@
Meteor.methods({ Meteor.methods({
removeMeasurement: function(id) { removeMeasurement: function(id) {
Measurements.remove(id); var lesionData = Measurements.findOne(id);
},
removeMeasurementsByPatientId: function(patientId) {
Measurements.remove({
patientId: patientId
});
},
decrementLesionNumbers: function(lesionData) {
// Update all Measurements to decrement the lesion numbers for those // Update all Measurements to decrement the lesion numbers for those
// that were created after the current lesion by 1 // that were created after the current lesion by 1
@ -42,5 +36,12 @@ Meteor.methods({
}, { }, {
multi: true multi: true
}); });
Measurements.remove(id);
},
removeMeasurementsByPatientId: function(patientId) {
Measurements.remove({
patientId: patientId
});
} }
}); });