CoWorker Nature
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / UserEditorApplet.js
index 395d170c0a76ce08b810814a72eaf9aa4bf5c20e..772cf2e7fc18deb8ec57ce34581573a1c0d38225 100644 (file)
@@ -12,8 +12,7 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet",
 
   construct : function(){
        this.base(arguments);
-       this.setLayout(new qx.ui.layout.VBox());
-       //this.setDecorator("tabview-pane");
+       this.setLayout(new qx.ui.layout.VBox(5));
   },
 
   properties : 
@@ -78,13 +77,17 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet",
                check:"org.argeo.ria.components.ViewSelection"
        },
        modified : {
-               init : false
+               init : false,
+               apply : "_applyModified"
        },
        rolesList : {
                
        },
        instanceId : {init:""},
-       instanceLabel : {init:"Editor"}         
+       instanceLabel : {init:"Editor"},
+       loaded : {
+               init : false
+       }
   },
 
   members :
@@ -103,7 +106,11 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet",
                        this.setInstanceLabel("User " + data);
                }
                this.setView(viewPane);
-               this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
+               this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));                
+               
+               // TOOLBAR
+               this.buttonGB = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, "right"));
+               this.add(this.buttonGB);
                
                // GROUPBOXES
                this.basicGB = new qx.ui.groupbox.GroupBox("Base Informations");
@@ -140,12 +147,19 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet",
                this.passGB.add(this.passPane.getContainer());
                
                this.naturesTab = new qx.ui.tabview.TabView("top");
-               this.simpleNature = new org.argeo.security.ria.components.SimpleUserNatureImpl();
                
+               this.simpleNature = new org.argeo.security.ria.components.SimpleUserNatureImpl();               
                var page1 = new qx.ui.tabview.Page(this.simpleNature.getNatureLabel());
                page1.setLayout(new qx.ui.layout.Dock());
                page1.add(this.simpleNature.getContainer(), {edge:"center"});
                this.naturesTab.add(page1);
+               
+               this.coWorkerNature = new org.argeo.security.ria.components.CoworkerNatureImpl();               
+               var page2 = new qx.ui.tabview.Page(this.coWorkerNature.getNatureLabel());
+               page2.setLayout(new qx.ui.layout.Dock());
+               page2.add(this.coWorkerNature.getContainer(), {edge:"center"});
+               this.naturesTab.add(page2);
+               
                this.naturesGB.add(this.naturesTab, {edge:"center"});
                                        
        },
@@ -163,6 +177,9 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet",
                this.simpleNature.addListener("modified", function(){
                        this.setModified(true);
                }, this);               
+               this.coWorkerNature.addListener("modified", function(){
+                       this.setModified(true);
+               }, this);               
        },
        
        _initializeGroupBox: function(groupBox){
@@ -170,16 +187,34 @@ qx.Class.define("org.argeo.security.ria.UserEditorApplet",
                groupBox.getChildrenContainer().setPadding(8);                  
        },
        
+       _applyModified : function(value){
+               if(value) this.getViewSelection().triggerEvent();
+       },
+       
        /**
         * Load a given row : the data passed must be a simple data array.
         * @param data {Element} The text xml description. 
         */
        load : function(userData){
+               if(this.getLoaded()){
+                       return;
+               }
                if(userData){
                        this.usernameField.setValue(userData);
                }
                this.setRolesList(["ROLE_ADMIN", "ROLE_USER"]);
                this._attachListeners();
+               var title = new qx.ui.basic.Atom(this.getInstanceLabel(), "org.argeo.security.ria/preferences-user.png");
+               title.setFont(qx.bom.Font.fromString("16px sans-serif bold"));                  
+               this.buttonGB.add(title);
+               this.buttonGB.add(new qx.ui.core.Spacer(), {flex:1});
+               var commands = this.getCommands();
+               var button = new qx.ui.form.Button("Save", "org.argeo.security.ria/document-save.png", commands["save_user"].command);                  
+               var button2 = new qx.ui.form.Button("Close", "org.argeo.security.ria/window-close.png", commands["close"].command);             
+               this.buttonGB.add(button);
+               this.buttonGB.add(button2);
+               this.setLoaded(true);
+               
        },
                 
        addScroll : function(){