Move removeCollections.js to server folder from both and check patientId while setting null array to toolState data

This commit is contained in:
Evren Ozkan 2015-11-24 11:55:10 -05:00
parent ca30e22464
commit e6fd2e60b0
3 changed files with 17 additions and 9 deletions

View File

@ -70,25 +70,31 @@ Template.viewerMain.helpers({
Template.viewerMain.events({ Template.viewerMain.events({
'click button#clearTools': function(e, template) { 'click button#clearTools': function(e, template) {
var contentId = template.data.contentId;
var patientId = template.data.studies[0].patientId;
var toolTypes = ["lesion", "nonTarget"]; var toolTypes = ["lesion", "nonTarget"];
var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState; var toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
var toolStateKeys = Object.keys(toolState).slice(0); var toolStateKeys = Object.keys(toolState).slice(0);
toolStateKeys.forEach(function (imageId) { toolStateKeys.forEach(function (imageId) {
toolTypes.forEach(function (toolType) { toolTypes.forEach(function (toolType) {
toolState[imageId][toolType] = { if(toolState[imageId][toolType]) {
data: [] if(toolState[imageId][toolType].data[0].patientId === patientId) {
}; toolState[imageId][toolType] = {
data: []
}
}
}
}); });
}); });
// Update imageViewerViewport elements // Update imageViewerViewport elements
$(".imageViewerViewport").each(function(viewportIndex, element) { $("#"+contentId+" .imageViewerViewport").each(function(viewportIndex, element) {
cornerstone.updateImage(element); cornerstone.updateImage(element);
}); });
// Remove patient's measurements // Remove patient's measurements
var patientId = template.data.studies[0].patientId;
Meteor.call('removeMeasurementsByPatientId', patientId); Meteor.call('removeMeasurementsByPatientId', patientId);
} }

View File

@ -48,10 +48,10 @@ Package.onUse(function (api) {
// Server functions // Server functions
api.addFiles('server/collections.js', 'server'); api.addFiles('server/collections.js', 'server');
api.addFiles('server/removeCollections.js', ['server']);
// Both client and server functions // Both client and server functions
api.addFiles('both/collections.js', ['client', 'server']); api.addFiles('both/collections.js', ['client', 'server']);
api.addFiles('both/removeCollections.js', ['client', 'server']);
// Library functions // Library functions

View File

@ -1,8 +1,10 @@
Meteor.methods({ Meteor.methods({
"removeMeasurementsByPatientId": function(patientId) { "removeMeasurementsByPatientId": function(patientId) {
Measurements.remove( Measurements.remove(
{patientId: patientId}, {patientId: patientId}
{multi: true}
); );
} }
});
});