Preventing duplicated deletion dialogs
This commit is contained in:
parent
4a6b700f31
commit
4aa0204119
@ -17,6 +17,14 @@ const toolTypes = [
|
|||||||
'rectangleRoi'
|
'rectangleRoi'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Flag to prevent dialog from being displayed twice
|
||||||
|
let locked = false;
|
||||||
|
|
||||||
|
// Handler to unlock the keydown handling
|
||||||
|
const unlock = () => {
|
||||||
|
locked = false;
|
||||||
|
};
|
||||||
|
|
||||||
function removeMeasurementTimepoint(data, index, toolType, element) {
|
function removeMeasurementTimepoint(data, index, toolType, element) {
|
||||||
let { imageId } = data;
|
let { imageId } = data;
|
||||||
if (!imageId) {
|
if (!imageId) {
|
||||||
@ -72,6 +80,9 @@ function getNearbyToolData(element, coords) {
|
|||||||
function keyDownCallback(event, eventData) {
|
function keyDownCallback(event, eventData) {
|
||||||
const keyCode = eventData.which;
|
const keyCode = eventData.which;
|
||||||
|
|
||||||
|
// Stop here if the locked flag is set to true
|
||||||
|
if (locked) return;
|
||||||
|
|
||||||
if (keyCode === keys.DELETE ||
|
if (keyCode === keys.DELETE ||
|
||||||
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
(keyCode === keys.D && eventData.event.ctrlKey === true)) {
|
||||||
|
|
||||||
@ -86,15 +97,19 @@ function keyDownCallback(event, eventData) {
|
|||||||
position: eventData.currentPoints.page
|
position: eventData.currentPoints.page
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set the locked flag to true
|
||||||
|
locked = true;
|
||||||
|
|
||||||
// TODO= Refactor this so the confirmation dialog is an
|
// TODO= Refactor this so the confirmation dialog is an
|
||||||
// optional settable callback in the tool's configuration
|
// optional settable callback in the tool's configuration
|
||||||
OHIF.ui.showDialog('dialogConfirm', dialogSettings).then(() => {
|
OHIF.ui.showDialog('dialogConfirm', dialogSettings).then(() => {
|
||||||
|
unlock();
|
||||||
removeMeasurementTimepoint(nearbyToolData.tool,
|
removeMeasurementTimepoint(nearbyToolData.tool,
|
||||||
nearbyToolData.index,
|
nearbyToolData.index,
|
||||||
nearbyToolData.toolType,
|
nearbyToolData.toolType,
|
||||||
eventData.element
|
eventData.element
|
||||||
);
|
);
|
||||||
});
|
}).catch(unlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user