From 5ce4bfe828cb96eecf4b7aba9fb49853c1e3c448 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 21 Mar 2012 14:19:15 -0400 Subject: [PATCH] custom org tree : admin ui Signed-off-by: Bill Erickson --- .../conify/global/actor/org_unit_custom_tree.js | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js b/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js index 34b61d0f63..cc835f79dc 100644 --- a/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js +++ b/Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js @@ -206,6 +206,7 @@ function applyChanges2() { prevTn = newTn; if (nodeList.length == 0) { progressDialog.hide(); + location.href = location.href; } else { progressDialog.update({maximum : nodeList.length, progress : ++progress}); traverseAndCreate(nodeList.shift()); @@ -217,10 +218,29 @@ function applyChanges2() { } 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) + } + ); } ); } -- 2.11.0