Bug fixes for confirmDelete and lesion management

This commit is contained in:
Erik Ziegler committed 2015-12-21 09:29:19 -05:00
1 parent 5eb8a717cb
commit 4ae0183a9c
6 files changed
+43 -14

No files matched your search

@@ -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);
}
}
});