svn commit: samba r21252 - in branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse: .

idra at samba.org idra at samba.org
Thu Feb 8 23:19:32 GMT 2007


Author: idra
Date: 2007-02-08 23:19:31 +0000 (Thu, 08 Feb 2007)
New Revision: 21252

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21252

Log:

Add operation works now, still to do mod and del ops
Need to implement tree refresh as well


Modified:
   branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
   branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
   branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js


Changeset:
Modified: branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
===================================================================
--- branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js	2007-02-08 21:57:41 UTC (rev 21251)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js	2007-02-08 23:19:31 UTC (rev 21252)
@@ -198,7 +198,7 @@
           var request = _this.callRpc(fsm,
                                       "samba.ldb",
                                       ldbmod.getOpType(),
-				      [ ldif ]);
+				      [ dbHandle, ldif ]);
 
           // When we get the result, we'll need to know what type of request
           // we made.

Modified: branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
===================================================================
--- branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js	2007-02-08 21:57:41 UTC (rev 21251)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js	2007-02-08 23:19:31 UTC (rev 21252)
@@ -137,7 +137,11 @@
   case "search":
     this._displaySearchResults(module, rpcRequest);
     break;
-    
+
+  case "add":
+    this._displayCommitResults(module, rpcRequest, "add");
+    break;
+ 
   case "tree_open":
     this._displayTreeOpenResults(module, rpcRequest);
     break;
@@ -380,6 +384,15 @@
 
   // Add the button to the hlayout
   hlayout.add(this._modb);
+
+  hlayout.add(new qx.ui.basic.HorizontalSpacer());
+
+  // Add the "Delete" button
+  this._delb = new qx.ui.form.Button("Delete");
+  this._delb.addEventListener("execute", this._confirmDeleteRecord, this);
+
+  // Add the button to the hlayout
+  hlayout.add(this._delb);
   
   // Add the hlayout to the vlayout.
   vlayout.add(hlayout);
@@ -440,7 +453,8 @@
   this._ldbmod.setDisplay(false);
   this._newb.setEnabled(true);
   this._modb.setEnabled(true);
-}
+  this._delb.setEnabled(true);
+};
 
 qx.Proto._switchToNewrecord = function()
 {
@@ -448,8 +462,9 @@
   this._ldbmod.setDisplay(true);
   this._newb.setEnabled(false);
   this._modb.setEnabled(false);
+  this._delb.setEnabled(false);
   this._ldbmod.initNew(this._switchToNormal, this);
-}
+};
 
 qx.Proto._switchToModrecord = function()
 {
@@ -457,9 +472,84 @@
   this._ldbmod.setDisplay(true);
   this._newb.setEnabled(false);
   this._modb.setEnabled(false);
+  this._delb.setEnabled(false);
   this._ldbmod.initMod(this._table.getTableModel(), this._switchToNormal, this);
-}
+};
 
+qx.Proto._confirmDeleteRecord = function()
+{
+
+  var main = qx.ui.core.ClientDocument.getInstance();
+
+  if (this._dmw == null) {
+
+    this._dmw = new qx.ui.window.Window("New Attribute Name");
+    this._dmw.set({
+      width: 200,
+      height: 100,
+      modal: true,
+      centered: true,
+      restrictToPageOnOpen: true,
+      showMinimize: false,
+      showMaximize: false,
+      showClose: false,
+      resizeable: false
+    });
+
+    var warningLabel = new qx.ui.basic.Label("Are you sure you want to delete <record name here> ?");
+    this._dmw.add(warningLabel);
+
+    var cancelButton = new qx.ui.form.Button("Cancel");
+    cancelButton.addEventListener("execute", function() {
+      this._dmw.close();
+    }, this);
+    cancelButton.set({ top: 45, left: 32 }); 
+    this._dmw.add(cancelButton);
+
+    this._dmw.addEventListener("appear",function() { 
+      cancelButton.focus();
+    }, this._dmw);
+
+    main.add(this._dmw);
+    var okButton = new qx.ui.form.Button("OK");
+    okButton.addEventListener("execute", function() {
+      //TODO: call search.addEventListener("execute", fsm.eventListener, fsm);
+      
+      this._dmw.close();
+    }, this);
+    okButton.set({ top: 45, right: 32 });
+    this._dmw.add(okButton);
+
+    main.add(this._dmw);
+  }
+
+  this._dmw.open();
+};
+
+qx.Proto._displayCommitResults = function(module, rpcRequest, type)
+{
+  var result = rpcRequest.getUserData("result");
+
+  switch (type) {
+  case "add":
+    alert("Object successfully added!");
+    break;
+
+  case "modify":
+    alert("Object successfully modified!");
+    break;
+
+  case "delete":
+    alert("Object Successfully deleted!");
+    break;
+  }
+
+  this._switchToNormal();
+
+  //TODO: reload tree after add or delete
+
+};
+
 qx.Proto._displaySearchResults = function(module, rpcRequest)
 {
   var fsm = module.fsm;

Modified: branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
===================================================================
--- branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js	2007-02-08 21:57:41 UTC (rev 21251)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js	2007-02-08 23:19:31 UTC (rev 21252)
@@ -158,6 +158,8 @@
     var row = tablemodel.getRowData(i);
     this._addNewAttribute(row[0], row[1]);
   }
+
+  this._modBaseTableModel = tablemodel;
 }
 
 qx.Proto._setExitCallback = function(vFunction, vObject) {
@@ -215,11 +217,6 @@
 
 qx.Proto._addNewAttribute = function(name, value, before) {
 
-  // do not add a new attribute if the name is null
-  if (name == null || name == "") {
-    return;
-  }
-
   var hlayout = new qx.ui.layout.HorizontalBoxLayout();
   hlayout.set({ width: "auto", height: "auto", spacing: 10 });
 
@@ -229,11 +226,11 @@
     this._addNewAttribute(name, null, hlayout);
   }, this);
 
-  var aLabel = new qx.ui.basic.Label(name);
-  aLabel.setWidth(150);
+  var aNameTextField = new qx.ui.form.TextField(name);
+  aNameTextField.setWidth(150);
 
-  var aTextField = new qx.ui.form.TextField(value);
-  aTextField.setWidth(250);
+  var aValTextField = new qx.ui.form.TextField(value);
+  aValTextField.setWidth(250);
 
   var rButton = new qx.ui.form.Button("-");
   rButton.set({ left: 5, width: 15, height: 15});
@@ -241,9 +238,9 @@
     hlayout.setParent(null);
   }, this);
 
-  hlayout.add(aButton, aLabel, aTextField, rButton);
-  hlayout.setUserData("attrName", name);
-  hlayout.setUserData("attrVal", aTextField);
+  hlayout.add(aButton, aNameTextField, aValTextField, rButton);
+  hlayout.setUserData("attrName", aNameTextField);
+  hlayout.setUserData("attrVal", aValTextField);
 
   if (before) {
     this._attrArea.addAfter(hlayout, before);
@@ -253,64 +250,13 @@
   }
 }
 
-qx.Proto._createNewAttribute = function() {
-
-  var main = qx.ui.core.ClientDocument.getInstance();
-
-  if (this._amw == null) {
-
-    this._amw = new qx.ui.window.Window("New Attribute Name");
-    this._amw.set({
-      width: 200,
-      height: 70,
-      modal: true,
-      centered: true,
-      restrictToPageOnOpen: true,
-      showMinimize: false,
-      showMaximize: false,
-      showClose: false,
-      resizeable: false
-    });
-
-    attrName = new qx.ui.form.TextField();
-    var enterCommand = new qx.client.Command("Enter");
-    enterCommand.addEventListener("execute", function() { 
-      this._addNewAttribute(attrName.getComputedValue());
-      this._amw.close();
-    }, this);
-    attrName.set({ top: 15, left: 10, command: enterCommand });
-    this._amw.add(attrName);
-
-    this._amw.setUserData("textfield", attrName);
- 
-    var okButton = new qx.ui.form.Button("OK");
-    okButton.addEventListener("execute", function() {
-      this._addNewAttribute(attrName.getValue());
-      this._amw.close();
-    }, this);
-    okButton.set({ top: 12, left: 155 });
-    this._amw.add(okButton);
-
-    this._amw.addEventListener("appear",function() {
-      attrName.focus();
-    }, this._amw);
-  
-    main.add(this._amw);
-  }
-  else {
-    this._amw.getUserData("textfield").setValue("");
-  }
-
-  this._amw.open();
-}
-
 qx.Proto._createAttributesArea = function() {
 
   this._attrArea = new qx.ui.layout.VerticalBoxLayout();
 
   this._attrAddButton = new qx.ui.form.Button("+");
   this._attrAddButton.set({ width: 15, height: 15});
-  this._attrAddButton.addEventListener("execute", this._createNewAttribute, this);
+  this._attrAddButton.addEventListener("execute", this._addNewAttribute, this);
 
   this._attrArea.add(this._attrAddButton);
 
@@ -334,7 +280,7 @@
 
   for (var i = 0; i < c.length; i++) {
     if (c[i] instanceof qx.ui.layout.HorizontalBoxLayout) {
-      ldif = ldif + c[i].getUserData("attrName") + ": " + c[i].getUserData("attrVal").getComputedValue() + "\n";
+      ldif = ldif + c[i].getUserData("attrName").getComputedValue() + ": " + c[i].getUserData("attrVal").getComputedValue() + "\n";
     }
   }
   // terminate ldif record



More information about the samba-cvs mailing list