- Updating the state of the enable/disable button in the toolbar when appropriate.
This commit is contained in:
Matt Gilman 2014-12-30 07:43:20 -05:00
parent 6f1c12f5ef
commit d27d2e303e
1 changed files with 16 additions and 1 deletions

View File

@ -148,11 +148,26 @@ nf.CanvasToolbar = (function () {
});
// if there are any colorable components enable the button
if (nf.Common.isDefinedAndNotNull(colorableComponents) && colorableComponents.size() === 1 && colorableComponents.size() === selection.size()) {
if (colorableComponents.size() === 1 && colorableComponents.size() === selection.size()) {
actions['fill'].enable();
} else {
actions['fill'].disable();
}
// determine if there are any selected components that support enable/disable
var supportsEnable = selection.filter(function(d) {
var selected = d3.select(this);
return nf.CanvasUtils.isProcessor(selected) || nf.CanvasUtils.isInputPort(selected) || nf.CanvasUtils.isOutputPort(selected);
});
// ensure the entire selection supports enable/disable
if (!supportsEnable.empty() && supportsEnable.size() === selection.size()) {
actions['enable'].enable();
actions['disable'].enable();
} else {
actions['enable'].disable();
actions['disable'].disable();
}
}
}
};