summaryrefslogtreecommitdiff
path: root/webapps/swat/source
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-02-04 19:21:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:44:32 -0500
commite587d7e2dd9fe6ff57c7651fdb13a67fc474b659 (patch)
treeae77832de8ccf81d75bd17ce922eafda7b962bca /webapps/swat/source
parent744dddd75be73e4e883241b808b37a12a7a39ac1 (diff)
downloadsamba-e587d7e2dd9fe6ff57c7651fdb13a67fc474b659.tar.gz
samba-e587d7e2dd9fe6ff57c7651fdb13a67fc474b659.tar.bz2
samba-e587d7e2dd9fe6ff57c7651fdb13a67fc474b659.zip
r21136: First attempt at implementing add/modify rpc calls.
The code does not work, but Derrell asked me to commit to analyze the problem. Simo. (This used to be commit 433591c430891fd5f0859fe3b685287b4fb166e5)
Diffstat (limited to 'webapps/swat/source')
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js46
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Gui.js2
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js41
3 files changed, 83 insertions, 6 deletions
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
index b28a3eb168..b58f4bbaf6 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
@@ -82,7 +82,10 @@ qx.Proto.buildFsm = function(module)
"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 @@ qx.Proto.buildFsm = function(module)
/*
* 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:
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
index 38f8314bb4..161b99b19a 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
@@ -418,7 +418,7 @@ qx.Proto._buildPageBrowse = function(module, page)
// Not displayed by default
this._ldbmod.setDisplay(false);
- fsm.addObject("ldbmod:browse", this._ldbmod);
+ fsm.addObject("ldbmod", this._ldbmod);
splitpane.addRight(this._ldbmod);
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js b/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
index cb1b326d7c..6967a7c353 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
@@ -42,7 +42,7 @@ function(fsm)
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 @@ function(fsm)
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 @@ qx.Proto.setBase = function(base) {
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 @@ qx.Proto.initNew = function(callback, obj) {
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 @@ qx.Proto._cancelOp = function() {
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 @@ qx.Proto._addNewAttribute = function(name, value, before) {
}, 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 @@ qx.Proto._createAttributesArea = function() {
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;
+}