Bug fixes for confirmDelete and lesion management
This commit is contained in:
parent
5eb8a717cb
commit
4ae0183a9c
@ -44,7 +44,7 @@ Template.viewer.onCreated(function() {
|
||||
},
|
||||
nonTarget: function() {
|
||||
toolManager.setActiveTool("nonTarget");
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
// The hotkey can also be an array (e.g. ["NUMPAD0", "0"])
|
||||
|
||||
@ -37,7 +37,7 @@ var LesionManager = (function() {
|
||||
|
||||
// Find the specific lesion to be updated
|
||||
var existingMeasurement;
|
||||
if (lesionData.id) {
|
||||
if (lesionData.id && lesionData.id !== 'notready') {
|
||||
existingMeasurement = Measurements.findOne(lesionData.id);
|
||||
} else {
|
||||
existingMeasurement = Measurements.findOne({
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
// TODO = Check if we have the same function already in Cornerstone Tools
|
||||
function getNearbyToolData(element, coords, toolTypes) {
|
||||
var allTools = toolManager.getTools();
|
||||
var pointNearTool = false;
|
||||
@ -77,11 +78,17 @@
|
||||
var toolTypes = ["lesion", "nonTarget"];
|
||||
var nearbyToolData = getNearbyToolData(eventData.element, eventData.currentPoints.canvas, toolTypes);
|
||||
|
||||
if (nearbyToolData) {
|
||||
removeMeasurementTimepoint(nearbyToolData.nearbyTool,
|
||||
nearbyToolData.nearbyToolIndex,
|
||||
nearbyToolData.nearbyToolType);
|
||||
if (!nearbyToolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO= Refactor this so the confirmation dialog is an
|
||||
// optional settable callback in the tool's configuration
|
||||
showConfirmDialog(function() {
|
||||
removeMeasurementTimepoint(nearbyToolData.nearbyTool,
|
||||
nearbyToolData.nearbyToolIndex,
|
||||
nearbyToolData.nearbyToolType);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div id="confirmDeleteDialog">
|
||||
<h5>Remove Measurement?</h5>
|
||||
<p>Are you sure you would like to remove this measurement?</p>
|
||||
<button id="cancel" class="btn btn-link">Cancel</button>
|
||||
<button id="confirm" class="btn btn-primary">OK</button>
|
||||
<button id="cancel" class="btn btn-link" tabindex="1">Cancel</button>
|
||||
<button id="confirm" class="btn btn-primary" tabindex="0">OK</button>
|
||||
</div>
|
||||
</template>
|
||||
@ -9,9 +9,10 @@ function closeHandler() {
|
||||
delete Template.confirmDeleteDialog.doneCallback;
|
||||
}
|
||||
|
||||
showConfirmDialog = function(doneCallback) {
|
||||
showConfirmDialog = function(doneCallback, options) {
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
options = options || {};
|
||||
UI.renderWithData(Template.removableBackdrop, options, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$(".removableBackdrop").one('mousedown touchstart', function() {
|
||||
@ -25,13 +26,17 @@ showConfirmDialog = function(doneCallback) {
|
||||
}
|
||||
};
|
||||
|
||||
var keys = {
|
||||
ESC: 27,
|
||||
ENTER: 13
|
||||
};
|
||||
|
||||
Template.confirmDeleteDialog.events({
|
||||
'click #cancel, click #close': function() {
|
||||
closeHandler();
|
||||
},
|
||||
'click #confirm': function() {
|
||||
var doneCallback = Template.confirmDeleteDialog.doneCallback;
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback();
|
||||
}
|
||||
@ -39,12 +44,22 @@ Template.confirmDeleteDialog.events({
|
||||
closeHandler();
|
||||
},
|
||||
'keypress #confirmDeleteDialog': function(e) {
|
||||
if (e.which === keys.ESC) {
|
||||
closeHandler();
|
||||
}
|
||||
|
||||
if (this.keyPressAllowed === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
var doneCallback = Template.confirmDeleteDialog.doneCallback;
|
||||
|
||||
// If Enter is pressed, close the dialog
|
||||
if (e.which === 13) {
|
||||
if (e.which === keys.ENTER) {
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback();
|
||||
}
|
||||
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,15 +34,22 @@ Template.lesionTableRow.events({
|
||||
},
|
||||
'keydown .location': function(e) {
|
||||
var keyCode = e.which;
|
||||
|
||||
if (keyCode === keys.DELETE ||
|
||||
(keyCode === keys.D && e.ctrlKey === true)) {
|
||||
var currentMeasurement = this;
|
||||
var options = {
|
||||
keyPressAllowed: false
|
||||
};
|
||||
|
||||
showConfirmDialog(function() {
|
||||
Meteor.call("removeMeasurement", currentMeasurement._id, function(error, response) {
|
||||
console.log('Removed!');
|
||||
if (error) {
|
||||
log.warn(error);
|
||||
}
|
||||
log.info(response);
|
||||
});
|
||||
});
|
||||
}, options);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user