LT-115: Set CRUNEX tool buttons as disabled if timepoint is baseline
- Remove addDisabledTool and getDisabledTool methods in toolManager - Add disabledToolButtons array in toolDefaultStates to check enable/disable buttons
This commit is contained in:
parent
161bbba5cf
commit
76a9f6a894
@ -33,15 +33,4 @@ pixelSpacingAutorunCheck = function() {
|
|||||||
oncologyTools.prop('disabled', false);
|
oncologyTools.prop('disabled', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set disabled/enabled timepoint buttons
|
|
||||||
var imageId = enabledElement.image.imageId;
|
|
||||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
|
||||||
|
|
||||||
// Find the relevant timepoint given the current study
|
|
||||||
var timepoint = Timepoints.findOne({
|
|
||||||
studyInstanceUids: {
|
|
||||||
$in: [study.studyInstanceUid]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setTimepointTools(timepoint);
|
|
||||||
};
|
};
|
||||||
@ -1,21 +1,33 @@
|
|||||||
// If timepoint is baseline, sets lesion tool as active tool
|
// If timepoint is baseline, sets lesion tool as active tool
|
||||||
setTimepointTools = function(timepoint) {
|
setTimepointTools = function(timepoint) {
|
||||||
|
|
||||||
// Enabled tools for only follow-up tools
|
var disabledBaselineTools = ["crunexTools"];
|
||||||
var fuTools = ["button#crunexTools"];
|
var states = toolManager.getToolDefaultStates();
|
||||||
var fuToolsJQ = $("button#crunexTools");
|
var disabledToolButtons = states.disabledToolButtons;
|
||||||
var isDisabled = false;
|
|
||||||
if ((timepoint.timepointType).toLowerCase() === "baseline") {
|
if ((timepoint.timepointType).toLowerCase() === "baseline") {
|
||||||
// Set active tool as lesion tool
|
// Set active tool as lesion tool
|
||||||
toolManager.setActiveTool('bidirectional');
|
toolManager.setActiveTool('bidirectional');
|
||||||
isDisabled = true;
|
disabledBaselineTools.forEach(function(tool) {
|
||||||
|
var index = disabledToolButtons.indexOf(tool);
|
||||||
|
if (index === -1) {
|
||||||
|
disabledToolButtons.push(tool);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
toolManager.setActiveTool(toolManager.getDefaultTool());
|
toolManager.setActiveTool(toolManager.getDefaultTool());
|
||||||
isDisabled = false;
|
// Remove disabled baseline tools
|
||||||
|
disabledBaselineTools.forEach(function(tool) {
|
||||||
|
var index = disabledToolButtons.indexOf(tool);
|
||||||
|
if (index !== -1) {
|
||||||
|
disabledToolButtons.splice(index, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toolManager.addDisabledTool({tools: fuTools, status: isDisabled});
|
states.disabledToolButtons = disabledToolButtons;
|
||||||
fuToolsJQ.prop('disabled', isDisabled);
|
toolManager.setToolDefaultStates(states);
|
||||||
};
|
};
|
||||||
|
|
||||||
timepointAutoCheck = function(templateData) {
|
timepointAutoCheck = function(templateData) {
|
||||||
|
|||||||
@ -108,17 +108,6 @@ function getDefaultButtonData() {
|
|||||||
return buttonData;
|
return buttonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setButtonsDisability() {
|
|
||||||
var disabledTools = toolManager.getDisabledTool();
|
|
||||||
disabledTools.forEach(function(toolData) {
|
|
||||||
var tools = toolData.tools;
|
|
||||||
var status = toolData.status;
|
|
||||||
tools.forEach(function(element) {
|
|
||||||
$(element).prop("disabled", status);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Template.toolbar.events({
|
Template.toolbar.events({
|
||||||
'click .imageViewerTool': function(e) {
|
'click .imageViewerTool': function(e) {
|
||||||
$(e.currentTarget).tooltip('hide');
|
$(e.currentTarget).tooltip('hide');
|
||||||
@ -159,7 +148,19 @@ Template.toolbar.onRendered(function() {
|
|||||||
extraTooltipButtons.tooltip(OHIF.viewer.tooltipConfig);
|
extraTooltipButtons.tooltip(OHIF.viewer.tooltipConfig);
|
||||||
|
|
||||||
// Set disabled/enabled tool buttons that are set in toolManager
|
// Set disabled/enabled tool buttons that are set in toolManager
|
||||||
setButtonsDisability();
|
var states = toolManager.getToolDefaultStates();
|
||||||
|
var disabledToolButtons = states.disabledToolButtons;
|
||||||
|
var allToolbarButtons = $("#toolbar").find("button");
|
||||||
|
if (disabledToolButtons.length > 0) {
|
||||||
|
for (var i=0; i < allToolbarButtons.length; i++) {
|
||||||
|
var toolbarButton = allToolbarButtons[i];
|
||||||
|
$(toolbarButton).prop("disabled", false);
|
||||||
|
var index = disabledToolButtons.indexOf($(toolbarButton).attr("id"));
|
||||||
|
if (index !== -1) {
|
||||||
|
$(toolbarButton).prop("disabled", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.toolbar.helpers({
|
Template.toolbar.helpers({
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
var activeTool = "wwwc";
|
var activeTool = "wwwc";
|
||||||
var defaultTool = "wwwc";
|
var defaultTool = "wwwc";
|
||||||
var disabledTools = [];
|
|
||||||
|
|
||||||
var tools = {};
|
var tools = {};
|
||||||
|
|
||||||
@ -8,7 +7,8 @@ var toolDefaultStates = {
|
|||||||
activate: [],
|
activate: [],
|
||||||
deactivate: [],
|
deactivate: [],
|
||||||
enable: [],
|
enable: [],
|
||||||
disable: []
|
disable: [],
|
||||||
|
disabledToolButtons: []
|
||||||
};
|
};
|
||||||
|
|
||||||
var initialized = false;
|
var initialized = false;
|
||||||
@ -121,7 +121,7 @@ toolManager = {
|
|||||||
// Enable tools based on their default states
|
// Enable tools based on their default states
|
||||||
Object.keys(toolDefaultStates).forEach(function(action) {
|
Object.keys(toolDefaultStates).forEach(function(action) {
|
||||||
var relevantTools = toolDefaultStates[action];
|
var relevantTools = toolDefaultStates[action];
|
||||||
if (!relevantTools || !relevantTools.length) {
|
if (!relevantTools || !relevantTools.length || action === 'disabledToolButtons') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,11 +219,6 @@ toolManager = {
|
|||||||
},
|
},
|
||||||
getDefaultTool: function() {
|
getDefaultTool: function() {
|
||||||
return defaultTool;
|
return defaultTool;
|
||||||
},
|
|
||||||
addDisabledTool: function(toolData) {
|
|
||||||
disabledTools.push(toolData);
|
|
||||||
},
|
|
||||||
getDisabledTool: function() {
|
|
||||||
return disabledTools;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user