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);
|
||||
}
|
||||
|
||||
// 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
|
||||
setTimepointTools = function(timepoint) {
|
||||
|
||||
// Enabled tools for only follow-up tools
|
||||
var fuTools = ["button#crunexTools"];
|
||||
var fuToolsJQ = $("button#crunexTools");
|
||||
var isDisabled = false;
|
||||
var disabledBaselineTools = ["crunexTools"];
|
||||
var states = toolManager.getToolDefaultStates();
|
||||
var disabledToolButtons = states.disabledToolButtons;
|
||||
|
||||
if ((timepoint.timepointType).toLowerCase() === "baseline") {
|
||||
// Set active tool as lesion tool
|
||||
toolManager.setActiveTool('bidirectional');
|
||||
isDisabled = true;
|
||||
disabledBaselineTools.forEach(function(tool) {
|
||||
var index = disabledToolButtons.indexOf(tool);
|
||||
if (index === -1) {
|
||||
disabledToolButtons.push(tool);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
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});
|
||||
fuToolsJQ.prop('disabled', isDisabled);
|
||||
states.disabledToolButtons = disabledToolButtons;
|
||||
toolManager.setToolDefaultStates(states);
|
||||
};
|
||||
|
||||
timepointAutoCheck = function(templateData) {
|
||||
|
||||
@ -108,17 +108,6 @@ function getDefaultButtonData() {
|
||||
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({
|
||||
'click .imageViewerTool': function(e) {
|
||||
$(e.currentTarget).tooltip('hide');
|
||||
@ -159,7 +148,19 @@ Template.toolbar.onRendered(function() {
|
||||
extraTooltipButtons.tooltip(OHIF.viewer.tooltipConfig);
|
||||
|
||||
// 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({
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
var activeTool = "wwwc";
|
||||
var defaultTool = "wwwc";
|
||||
var disabledTools = [];
|
||||
|
||||
var tools = {};
|
||||
|
||||
@ -8,7 +7,8 @@ var toolDefaultStates = {
|
||||
activate: [],
|
||||
deactivate: [],
|
||||
enable: [],
|
||||
disable: []
|
||||
disable: [],
|
||||
disabledToolButtons: []
|
||||
};
|
||||
|
||||
var initialized = false;
|
||||
@ -121,7 +121,7 @@ toolManager = {
|
||||
// Enable tools based on their default states
|
||||
Object.keys(toolDefaultStates).forEach(function(action) {
|
||||
var relevantTools = toolDefaultStates[action];
|
||||
if (!relevantTools || !relevantTools.length) {
|
||||
if (!relevantTools || !relevantTools.length || action === 'disabledToolButtons') {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -219,11 +219,6 @@ toolManager = {
|
||||
},
|
||||
getDefaultTool: function() {
|
||||
return defaultTool;
|
||||
},
|
||||
addDisabledTool: function(toolData) {
|
||||
disabledTools.push(toolData);
|
||||
},
|
||||
getDisabledTool: function() {
|
||||
return disabledTools;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user