BUGFIX Open selected node by default when entering batch actions to trigger loading of children and avoid "missed" nodes in any batch selection

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@81459 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-07-09 05:40:45 +00:00
parent fece6769fe
commit 7147a863b8

View File

@ -296,12 +296,20 @@ batchactionsclass.prototype = {
batchActionGlobals.selectedNodes = { }; batchActionGlobals.selectedNodes = { };
var sel = $('sitetree').firstSelected(); var selectedNode = $('sitetree').firstSelected();
if(sel && sel.className.indexOf('nodelete') == -1) { if(selectedNode && selectedNode.className.indexOf('nodelete') == -1) {
var selIdx = $('sitetree').getIdxOf(sel); var selIdx = $('sitetree').getIdxOf(selectedNode);
batchActionGlobals.selectedNodes[selIdx] = true; batchActionGlobals.selectedNodes[selIdx] = true;
sel.removeNodeClass('current'); selectedNode.removeNodeClass('current');
sel.addNodeClass('selected'); selectedNode.addNodeClass('selected');
selectedNode.open();
// Open all existing children, which might trigger further
// ajaxExansion calls to ensure all nodes are selectable
var children = selectedNode.getElementsByTagName('li');
for(var i=0; i<children.length; i++) {
children[i].open();
}
} }
} }
} }
@ -315,7 +323,6 @@ batchActionGlobals = {
newNodes: { }, newNodes: { },
treeSelectionChanged : function(selectedNode) { treeSelectionChanged : function(selectedNode) {
var idx = $('sitetree').getIdxOf(selectedNode); var idx = $('sitetree').getIdxOf(selectedNode);
if(selectedNode.className.indexOf('nodelete') == -1) { if(selectedNode.className.indexOf('nodelete') == -1) {
if(selectedNode.selected) { if(selectedNode.selected) {
selectedNode.removeNodeClass('selected'); selectedNode.removeNodeClass('selected');