prevTn = newTn;
if (nodeList.length == 0) {
progressDialog.hide();
+ location.href = location.href;
} else {
progressDialog.update({maximum : nodeList.length, progress : ++progress});
traverseAndCreate(nodeList.shift());
}
function deleteSelected() {
+ var toDelete = [];
+
+ function collectChildren(item) {
+ toDelete.push(item);
+ magicTree.model.store.fetch({
+ query : {parent_ou : item.id[0]+''},
+ onComplete : function(list) {
+ dojo.forEach(list, collectChildren)
+ }
+ });
+ }
+
magicTree.dndController.getSelectedItems().forEach(
function(item) {
- if (item !== magicTree.model.root)
- magicTree.model.store.deleteItem(item);
+ if (item === magicTree.model.root) return
+ collectChildren(item);
+ // delete node plus children, starting at the leaf nodes
+ dojo.forEach(toDelete.reverse(),
+ function(i) {
+ console.log('Deleting item ' + i.id);
+ magicTree.model.store.deleteItem(i)
+ }
+ );
}
);
}