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

idra at samba.org idra at samba.org
Fri Feb 2 17:38:04 GMT 2007


Author: idra
Date: 2007-02-02 17:38:04 +0000 (Fri, 02 Feb 2007)
New Revision: 21126

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

Log:

Enhance the modal window so that it gets focus and just presing enter works.
Still I don't see the cursor :(

Swap -/+ buttons, you risk to delete an attribute by mistake when instead you want to add a new one,
and you might even not notice it.

Simo.


Modified:
   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/LdbModify.js
===================================================================
--- branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js	2007-02-02 17:30:10 UTC (rev 21125)
+++ branches/SAMBA_4_0/webapps/swat/source/class/swat/module/ldbbrowse/LdbModify.js	2007-02-02 17:38:04 UTC (rev 21126)
@@ -57,6 +57,8 @@
   this._active = false;
 
   this.basedn = "";
+
+  this._amw = null;
 });
 
 qx.OO.addProperty({ name : "basedn", type : "string" });
@@ -214,11 +216,11 @@
   var hlayout = new qx.ui.layout.HorizontalBoxLayout();
   hlayout.set({ width: "auto", height: "auto", spacing: 10 });
 
-  var rButton = new qx.ui.form.Button("-");
-  rButton.set({ width: 15, height: 15});
-  rButton.addEventListener("execute", function() {
-    hlayout.setParent(null);
-  });
+  var aButton = new qx.ui.form.Button("+");
+  aButton.set({ width: 15, height: 15});
+  aButton.addEventListener("execute", function() {
+    this._addNewAttribute(name, null, hlayout);
+  }, this);
 
   var aLabel = new qx.ui.basic.Label(name);
   aLabel.setWidth(150);
@@ -226,17 +228,18 @@
   var aTextField = new qx.ui.form.TextField(value);
   aTextField.setWidth(250);
 
-  var aButton = new qx.ui.form.Button("+");
-  aButton.set({ left: 5, width: 15, height: 15});
-  aButton.addEventListener("execute", function() {
-    this._addNewAttribute(name, null, hlayout);
+  var rButton = new qx.ui.form.Button("-");
+  rButton.set({ left: 5, width: 15, height: 15});
+  rButton.addEventListener("execute", function() {
+    hlayout.setParent(null);
   }, this);
 
-  hlayout.add(rButton, aLabel, aTextField, aButton);
+  hlayout.add(aButton, aLabel, aTextField, rButton);
 
   if (before) {
     this._attrArea.addAfter(hlayout, before);
   } else {
+    //TODO: check the same attribute is not already present, if so just add a new value instead
     this._attrArea.addBefore(hlayout, this._attrAddButton);
   }
 }
@@ -245,39 +248,51 @@
 
   var main = qx.ui.core.ClientDocument.getInstance();
 
-  var amw = new qx.ui.window.Window("New Attribute Name");
-  amw.set({
-    width: 200,
-    height: 70,
-    modal: true,
-    centered: true,
-    restrictToPageOnOpen: true,
-    showMinimize: false,
-    showMaximize: false,
-    showClose: false,
-    resizeable: false
-  });
+  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
+    });
 
-  var attrName = new qx.ui.form.TextField();
-  attrName.addEventListener("execute", function() {
-    this._addNewAttribute(attrName.getValue());
-    amw.close();
-  }, this);
-  attrName.set({ top: 15, left: 10 });
-  amw.add(attrName);
+    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);
 
-  var okButton = new qx.ui.form.Button("OK");
-  okButton.addEventListener("execute", function() {
-    this._addNewAttribute(attrName.getValue());
-    amw.close();
-  }, this);
-  okButton.set({ top: 12, left: 155 });
-  amw.add(okButton);
+    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);
 
-  main.add(amw);
+    this._amw.addEventListener("appear",function() {
+      attrName.focus();
+    }, this._amw);
+  
+    main.add(this._amw);
+  }
+  else {
+    this._amw.getUserData("textfield").setValue("");
+  }
 
-  amw.open();
+  this._amw.open();
 }
 
 qx.Proto._createAttributesArea = function() {



More information about the samba-cvs mailing list