Custom Org Tree : Admin UI honors "activate" on new trees
authorBill Erickson <berick@esilibrary.com>
Fri, 30 Mar 2012 13:38:56 +0000 (09:38 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 2 Apr 2012 17:39:02 +0000 (13:39 -0400)
Previously, activating a new tree would work, but the UI did not update
to reflect it.  Now the activate link correctly turns into a de-activate
link and vice versa.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/conify/global/actor/org_unit_custom_tree.js

index cc835f7..695a9c4 100644 (file)
@@ -247,7 +247,15 @@ function deleteSelected() {
 
 function activateTree() {
     mTree.active('t');
-    if (mTree.isnew()) return;
+
+    if (mTree.isnew()) {
+        // before the tree exists, we can only activate the local copy
+        // the next save event will activate it
+        openils.Util.hide(dojo.byId('activate-tree'));
+        openils.Util.show(dojo.byId('deactivate-tree'), 'inline');
+        return;
+    }
+
     pcrud.update(mTree, {
         oncomplete : function() {
             openils.Util.hide(dojo.byId('activate-tree'));
@@ -258,7 +266,13 @@ function activateTree() {
 
 function deactivateTree() {
     mTree.active('f');
-    if (mTree.isnew()) return;
+
+    if (mTree.isnew()) {
+        openils.Util.hide(dojo.byId('deactivate-tree'));
+        openils.Util.show(dojo.byId('activate-tree'), 'inline');
+        return;
+    }
+
     pcrud.update(mTree, {
         oncomplete : function() {
             openils.Util.hide(dojo.byId('deactivate-tree'));