svn commit: samba r21136 - in
branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse:
.
idra at samba.org
idra at samba.org
Sun Feb 4 19:21:17 GMT 2007
Author: idra
Date: 2007-02-04 19:21:17 +0000 (Sun, 04 Feb 2007)
New Revision: 21136
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21136
Log:
First attempt at implementing add/modify rpc calls.
The code does not work, but Derrell asked me to commit to analyze the problem.
Simo.
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-04 07:17:03 UTC (rev 21135)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js 2007-02-04 19:21:17 UTC (rev 21136)
@@ -82,7 +82,10 @@
"execute" :
{
"search" :
- "Transition_Idle_to_AwaitRpcResult_via_search"
+ "Transition_Idle_to_AwaitRpcResult_via_search",
+
+ "commit" :
+ "Transition_Idle_to_AwaitRpcResult_via_commit"
},
// If a previously unexpanded tree node is expanded, issue a request
@@ -166,6 +169,47 @@
/*
* Transition: Idle to AwaitRpcResult
*
+ * Cause: "execute" on OK button
+ *
+ * Action:
+ * Commit modification or add new record to ldb
+ */
+ var trans = new qx.util.fsm.Transition(
+ "Transition_Idle_to_AwaitRpcResult_via_commit",
+ {
+ "nextState" :
+ "State_AwaitRpcResult",
+
+ "ontransition" :
+ function(fsm, event)
+ {
+ // Get our module descriptor
+ var module = fsm.getObject("swat.main.module");
+
+ // Retrieve the database handle
+ var dbHandle = module.dbHandle;
+
+ // Retrieve the ldbmod object
+ var ldbmod = fsm.getObject("ldbmod");
+
+ var ldif = ldbmod.getLdif();
+
+ // Issue a Search call
+ var request = _this.callRpc(fsm,
+ "samba.ldb",
+ ldbmod.getOpType(),
+ [ ldif ]);
+
+ // When we get the result, we'll need to know what type of request
+ // we made.
+ request.setUserData("requestType", ldbmod.getOpType());
+ }
+ });
+ state.addTransition(trans);
+
+ /*
+ * Transition: Idle to AwaitRpcResult
+ *
* Cause: "treeOpenWhileEmpty" on tree
*
* Action:
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-04 07:17:03 UTC (rev 21135)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js 2007-02-04 19:21:17 UTC (rev 21136)
@@ -418,7 +418,7 @@
// Not displayed by default
this._ldbmod.setDisplay(false);
- fsm.addObject("ldbmod:browse", this._ldbmod);
+ fsm.addObject("ldbmod", this._ldbmod);
splitpane.addRight(this._ldbmod);
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-04 07:17:03 UTC (rev 21135)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js 2007-02-04 19:21:17 UTC (rev 21136)
@@ -42,7 +42,7 @@
this._okbtn.addEventListener("execute", fsm.eventListener, fsm);
// We'll be receiving events on the object, so save its friendly name
- fsm.addObject("domod", this._okbtn, "swat.main.fsmUtils.disable_during_rpc");
+ fsm.addObject("commit", this._okbtn, "swat.main.fsmUtils.disable_during_rpc");
// Add the buttons to the hlayout
this._hlayout.add(this._leftSpacer, this._cancelbtn, this._okbtn);
@@ -51,7 +51,7 @@
this.add(this._mainArea, this._hlayout);
// By default this is a new record creator
- this._type = "new";
+ this._type = "add";
// By default this is inactive
this._active = false;
@@ -93,7 +93,7 @@
this.basedn = base;
if (this._active) {
- if (this._type == "new") {
+ if (this._type == "add") {
this._basedn.setValue(this.basedn);
this._basedn.setWidth(8 * this.basedn.length);
@@ -106,7 +106,7 @@
this._setExitCallback(callback, obj);
this._active = true;
- this._type = "new";
+ this._type = "add";
var hlayout = new qx.ui.layout.HorizontalBoxLayout();
hlayout.set({ height: "auto", spacing: 10 });
@@ -206,6 +206,13 @@
this._callExitCallback();
}
+qx.Proto._okOp = function() {
+
+ //TODO: disable ok/cancel buttons and call fsm instead
+ this._reset();
+ this._callExitCallback();
+}
+
qx.Proto._addNewAttribute = function(name, value, before) {
// do not add a new attribute if the name is null
@@ -235,6 +242,8 @@
}, this);
hlayout.add(aButton, aLabel, aTextField, rButton);
+ hlayout.setUserData("attrName", name);
+ hlayout.setUserData("attrVal", aTextField);
if (before) {
this._attrArea.addAfter(hlayout, before);
@@ -307,3 +316,27 @@
this._mainArea.add(this._attrArea);
}
+
+qx.Proto.getOpType = function() {
+ return this._type;
+}
+
+qx.Proto.getLdif = function() {
+ //TODO: modify
+ if (this._type != "add") {
+ return null;
+ }
+
+ var ldif = "# Add operation\n";
+ ldif = ldif + "dn: " + this._rdn + "," + this._basedn + "\n";
+
+ for (var c in this._attrArea.getChildren()) {
+ if (c instanceof qx.ui.layout.HorizontalBoxLayout) {
+ ldif = ldif + c.getUserData("attrName") + ": " + c.getUserData("attrVal").getValue() + "\n";
+ }
+ }
+ // terminate ldif record
+ ldif = ldif + "\n";
+
+ return ldif;
+}
More information about the samba-cvs
mailing list