r22487: Add a separate widget class for listing users and reposition
authorRafal Szczesniak <mimir@samba.org>
Mon, 23 Apr 2007 13:37:33 +0000 (13:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:51:32 +0000 (14:51 -0500)
things on NetManager's screen. Qooxdoo layout positioning can
be tricky sometimes...

rafal

webapps/swat/source/class/swat/module/netmgr/Gui.js
webapps/swat/source/class/swat/module/netmgr/UsersView.js [new file with mode: 0644]

index b78d484f51b45ffe5545ab3f5247f01736fda317..8e92f4753d3621fd630e3aec3d92b6c21c513307 100644 (file)
@@ -2,6 +2,7 @@
  * Copyright (C)  Rafal Szczesniak 2007
  */
 
+
 /**
  * Swat Net Manager class graphical user interface
  */
@@ -14,7 +15,6 @@ function()
 
 //qx.OO.addProperty({ name : "_tree", type : "object" });
 //qx.OO.addProperty({ name : "_panel", type : "object" });
-//qx.OO.addProperty({ name : "_view", type : "object" });
 //qx.OO.addProperty({ name : "_txtDomain", type : "object" });
 //qx.OO.addProperty({ name : "_txtUsername", type : "object" });
 
@@ -30,9 +30,9 @@ qx.Proto.buildGui = function(module)
   // Main layout composing the whole form
   var vlayout = new qx.ui.layout.VerticalBoxLayout();
   vlayout.set({
-                top: 20,
-                left: 20,
-                width: "100%",
+                top: 10,
+                left: 10,
+                right: 10,
                 bottom: 20
               });
 
@@ -70,37 +70,17 @@ qx.Proto.buildGui = function(module)
   // "Panel" for list view
   this._panel = new qx.ui.layout.VerticalBoxLayout();
   var panel = this._panel;
-  
+
+  // TODO: Find out what's causing this bug - specifying 'width' works fine,
+  // but setting 'right' instead does not which makes impossible to position
+  // the panel against right boundary of a box
   panel.set({
               top: 0,
               left: 10,
-              width: "80%",
+              width:"80%",
               height: "100%"
             });
 
-  // Setup some initial columns and (empty) item list - to be replaced soon
-  // with default view loading
-  var columns = { name : { label: "Name", width: 120, type: "text" }};
-  var items = [];
-
-  // Setup the list view
-  this._view = new qx.ui.listview.ListView(items, columns);
-  var view = this._view;
-  view.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
-  view.setBackgroundColor("white");
-  view.set({
-             top: 0,
-             left: 0,
-             width: "80%",
-             height: "100%"
-           });
-
-  // Give a list view name to handle
-  fsm.addObject("view", view);
-
-  // and the list view to the panel
-  panel.add(view);
-  
   // Add the tree view and panel for list view to the layout
   hlayout.add(tree);
   hlayout.add(panel);
@@ -110,8 +90,8 @@ qx.Proto.buildGui = function(module)
   statusLayout.set({
                      top: 10,
                      left: 0,
-                     right: 0,
-                     height: "100%"
+                     width: "100%",
+                     height: "20%"
                    });
 
   // First "column" of status fields
@@ -119,13 +99,13 @@ qx.Proto.buildGui = function(module)
   colALayout.set({
                   top: 0,
                   left: 0,
-                  width: 150,
+                  width: "25%",
                   height: "100%"
                 });
 
   // Domain name (credentials) - label and text box
   var statusDomain = new qx.ui.layout.HorizontalBoxLayout();
-  statusDomain.set({ top: 0, left: 0, width: "100%", height: 20,
+  statusDomain.set({ top: 0, left: 0, width: "100%", height: "auto",
                       verticalChildrenAlign: "middle" });
   
   var lblDomain = new qx.ui.basic.Atom();
@@ -141,7 +121,7 @@ qx.Proto.buildGui = function(module)
   
   // Username (credentials) - label and text box
   var statusUsername = new qx.ui.layout.HorizontalBoxLayout();
-  statusUsername.set({ top: 0, left: 0, width: "100%", height: 20,
+  statusUsername.set({ top: 0, left: 0, width: "100%", height: "auto",
                        verticalChildrenAlign: "middle" });
 
   var lblUsername = new qx.ui.basic.Atom();
@@ -281,7 +261,13 @@ qx.Proto._updateNetContextCreds = function(module, rpcRequest)
 qx.Proto._initUserManager = function(module, rpcRequest)
 {
   // Get obtained UsrCtx handle
-  var result = rpcRequest.getUserData("result").data;
+  var usrCtx = rpcRequest.getUserData("result").data;
+
+  // Create user view and pass the context
+  var view = new swat.module.netmgr.UsersView(module.fsm);
+  view.setUsrCtx(usrCtx);
+  
+  this._panel.add(view);
 };
 
 
diff --git a/webapps/swat/source/class/swat/module/netmgr/UsersView.js b/webapps/swat/source/class/swat/module/netmgr/UsersView.js
new file mode 100644 (file)
index 0000000..b1b16b6
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C)  Rafal Szczesniak 2007
+ */
+
+//qx.OO.addProperty({ name: "_fsm", type: "object"});
+//qx.OO.addProperty({ name: "_columns", type: "object"});
+//qx.OO.addProperty({ name: "_items", type: "object"});
+//qx.OO.addProperty({ name: "_view", type: "object" });
+
+/**
+ * Users View 
+ */
+qx.OO.defineClass("swat.module.netmgr.UsersView", qx.ui.layout.HorizontalBoxLayout,
+function(fsm)
+{
+  qx.ui.layout.HorizontalBoxLayout.call(this);
+
+  this._fsm = fsm;
+  
+  // Set the whole view panel size and spacing between boxes
+  this.set({ top: 0, left: 0, width: "100%", height: "100%" });
+  this.setSpacing(5);
+
+  // Provide vertical positioning of combo box and list view
+  var innerBox = new qx.ui.layout.VerticalBoxLayout();
+  innerBox.set({ top: 0, left: 0, width: "100%", height: "100%"});
+
+  // horizontal box for domain selection label and combo box
+  var selectDomainBox = new qx.ui.layout.HorizontalBoxLayout();
+  selectDomainBox.set({ top: 0, left: 0, width: "auto", height: "10%" });
+  selectDomainBox.setVerticalChildrenAlign("middle");
+  selectDomainBox.setSpacing(5);
+  
+  // Setup domain selection combo box
+  var lblDomain = new qx.ui.basic.Atom("Domain:");
+  lblDomain.setHorizontalChildrenAlign("right");
+  
+  var cmbDomain = new qx.ui.form.ComboBox();
+  cmbDomain.setEditable(false);
+
+  // Create an empty list view with sample column
+  this._columns = { username : { label: "Username", width: 150, type: "text" }};
+  this._items = [];
+  this._view = new qx.ui.listview.ListView(this._items, this._columns);
+  var view = this._view;
+  view.set({ top: 0, left: 0, width: "90%", height: "90%" });
+  view.setBorder(qx.renderer.border.BorderPresets.getInstance().shadow);
+
+  // Arrange widgets and boxes
+  selectDomainBox.add(lblDomain);
+  selectDomainBox.add(cmbDomain);
+
+  innerBox.add(selectDomainBox);
+  innerBox.add(view);
+
+  // place the inner box in the UsersView box
+  this.add(innerBox);
+});
+
+
+// UsrMgr context is required for any operation on user accounts
+qx.OO.addProperty({ name : "usrCtx", type : "number" });