r21328: Ok, now we can successfully modify the ldb and refresh the tree
authorSimo Sorce <idra@samba.org>
Wed, 14 Feb 2007 05:16:05 +0000 (05:16 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:48:13 +0000 (14:48 -0500)
but ...
- we have a problem with removeAll() in ldbmodify
- we seem to not properly cactch errors, we always return a "success"
  alert even if the operation is not successful :(
(This used to be commit 8ed568ae10e9068874c90058b9777658f1e58df5)

webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js

index a9db18b712639cea5be9b0f19c15944502b59ba9..b819c2aab4a54f200c7602b045e7e41f4133f62e 100644 (file)
@@ -138,10 +138,16 @@ qx.Proto.displayData = function(module, rpcRequest)
     this._displaySearchResults(module, rpcRequest);
     break;
 
-  case "add":
   case "modify":
+    this._displayModifyResults(module, rpcRequest);
+    break;
+
+  case "add":
+    this._displayAddResults(module, rpcRequest);
+    break;
   case "delete":
-    this._displayCommitResults(module, rpcRequest, requestType);
+    this._displayDeleteResults(module, rpcRequest);
     break;
  
   case "tree_open":
@@ -475,34 +481,51 @@ qx.Proto._switchToModrecord = function()
 qx.Proto._confirmDeleteRecord = function()
 {
   
-  //this._newb.setEnabled(false);
-  //this._modb.setEnabled(false);
-  //this._delb.setEnabled(false);
   this._ldbmod.showConfirmDelete();
 };
 
-qx.Proto._displayCommitResults = function(module, rpcRequest, type)
+qx.Proto._displayModifyResults = function(module, rpcRequest)
 {
-  var result = rpcRequest.getUserData("result");
+  var tree = module.fsm.getObject("tree");
+  tree.createDispatchDataEvent("changeSelection", tree.getSelectedNodes());
 
-  switch (type) {
-  case "add":
-    alert("Object successfully added!");
-    break;
+  alert("Object successfully modified!");
 
-  case "modify":
-    alert("Object successfully modified!");
-    break;
+  this._switchToNormal();
+  //this._ldbmod.postCleanUp();
+}
 
-  case "delete":
-    alert("Object Successfully deleted!");
-    break;
-  }
+qx.Proto._displayAddResults = function(module, rpcRequest)
+{
+  var result = rpcRequest.getUserData("result");
+
+  var tree = module.fsm.getObject("tree");
+  var node = tree.getSelectedNodes()[0];
+  
+  tree.getDataModel().prune(node.nodeId, false);
+  node.bOpened = false;
+  tree.toggleOpened(node);
+
+  alert("Object successfully added!");
 
   this._switchToNormal();
+  //this._ldbmod.postCleanUp();
+};
 
-  //TODO: reload tree after add or delete
+qx.Proto._displayDeleteResults = function(module, rpcRequest, type)
+{
+  var result = rpcRequest.getUserData("result");
+
+  var tree = module.fsm.getObject("tree");
+  var node = tree.getDataModel().getData()[tree.getSelectedNodes()[0].parentNodeId];
+  
+  tree.getDataModel().prune(node.nodeId, false);
+  node.bOpened = false;
+  tree.toggleOpened(node);
 
+  alert("Object Successfully deleted!");
+
+  this._ldbmod.setBase("");
 };
 
 qx.Proto._displaySearchResults = function(module, rpcRequest)
@@ -559,12 +582,14 @@ qx.Proto._displayTreeOpenResults = function(module, rpcRequest)
   var parentNode = rpcRequest.getUserData("parentNode");
   var attributes = rpcRequest.getUserData("attributes");
 
+  // Remove any existing children, they will be replaced by the result of this call (refresh)
+  dataModel.setData();
+
   // Any children?
   if (! result || result["length"] == 0)
   {
     // Nope.  Remove parent's expand/contract button.
     dataModel.setState(parentNode.nodeId, { bHideOpenClose : true });
-    dataModel.setData();
     return;
   }
 
index e9a7d4890f354f1488ef1f8fa5f48fff24e3a209..aff8ec0495d5e68e41bfee6013ce92d6f984f79e 100644 (file)
@@ -97,8 +97,7 @@ qx.Proto.setBase = function(base) {
   if (this._active) {
     if (this._type == "add") {
 
-      this._basedn.setValue(this.basedn);
-      this._basedn.setWidth(8 * this.basedn.length);
+      this._basedn.setHtml(this.basedn);
     }
   }
 }
@@ -113,6 +112,12 @@ qx.Proto.initNew = function(callback, obj) {
 
   this._setExitCallback(callback, obj);
 
+  if (this.basedn == "") {
+    alert("Please select the parent node in the tree first!");
+    this._callExitCallback();
+    return;
+  }
+
   this._active = true;
   this._type = "add";
 
@@ -130,8 +135,7 @@ qx.Proto.initNew = function(callback, obj) {
 
   // The basedn of the object
   // TODO: add validator
-  this._basedn = new qx.ui.form.TextField(this.basedn);
-  this._basedn.setWidth(8 * this.basedn.length);
+  this._basedn = new qx.ui.basic.Label(this.basedn);
 
   hlayout.add(dnlabel, this._rdn, dnsep, this._basedn);
 
@@ -211,18 +215,14 @@ qx.Proto._reset = function() {
   this._mainArea.removeAll();
   this._active = false;
   this._type = "null";
-  return;
 }
 
-qx.Proto._cancelOp = function() {
-
+qx.Proto.postCleanUp = function() {
   this._reset();
-  this._callExitCallback();
 }
 
-qx.Proto._okOp = function() {
+qx.Proto._cancelOp = function() {
 
-  //TODO: disable ok/cancel buttons and call fsm instead
   this._reset();
   this._callExitCallback();
 }
@@ -291,7 +291,7 @@ qx.Proto.getLdif = function() {
 
   case "add":
 
-    var ldif = "dn: " + this._rdn.getValue() + "," + this._basedn.getValue() + "\n";
+    var ldif = "dn: " + this._rdn.getValue() + "," + this.basedn + "\n";
 
     for (var i = 0; i < c.length; i++) {
       if (c[i] instanceof qx.ui.layout.HorizontalBoxLayout) {