summaryrefslogtreecommitdiff
path: root/webapps/swat/source
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-02-08 23:19:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:44:53 -0500
commit57a68c93178ee9e0159366a8b02af01a86e601f5 (patch)
treec493a5782d21595af6cd711d084c4f493c7c8d31 /webapps/swat/source
parentf68a4f3d60bea74a9fc348cae42943db39e9633b (diff)
downloadsamba-57a68c93178ee9e0159366a8b02af01a86e601f5.tar.gz
samba-57a68c93178ee9e0159366a8b02af01a86e601f5.tar.bz2
samba-57a68c93178ee9e0159366a8b02af01a86e601f5.zip
r21252: Add operation works now, still to do mod and del ops
Need to implement tree refresh as well (This used to be commit ed7e00e2a0ab2d2254959f53f7a4f661f9a4c1b3)
Diffstat (limited to 'webapps/swat/source')
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js2
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/Gui.js98
-rw-r--r--webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js76
3 files changed, 106 insertions, 70 deletions
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
index f595864383..ff8d34972a 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/Fsm.js
@@ -198,7 +198,7 @@ qx.Proto.buildFsm = function(module)
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.
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
index 99ceb7ccd6..ca124c3352 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/Gui.js
@@ -137,7 +137,11 @@ qx.Proto.displayData = function(module, rpcRequest)
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 @@ qx.Proto._buildPageBrowse = function(module, page)
// 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 @@ qx.Proto._switchToNormal = function()
this._ldbmod.setDisplay(false);
this._newb.setEnabled(true);
this._modb.setEnabled(true);
-}
+ this._delb.setEnabled(true);
+};
qx.Proto._switchToNewrecord = function()
{
@@ -448,8 +462,9 @@ qx.Proto._switchToNewrecord = function()
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,8 +472,83 @@ qx.Proto._switchToModrecord = function()
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)
{
diff --git a/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js b/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
index f28f4b1018..af6dd12dc3 100644
--- a/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
+++ b/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js
@@ -158,6 +158,8 @@ qx.Proto.initMod = function(tablemodel, callback, obj) {
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._okOp = function() {
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 @@ qx.Proto._addNewAttribute = function(name, value, before) {
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 @@ qx.Proto._addNewAttribute = function(name, value, before) {
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._addNewAttribute = function(name, value, before) {
}
}
-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 @@ qx.Proto.getLdif = function() {
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