- this.naturesManager = new org.argeo.security.ria.components.NaturesManager();
- var detectedNatures = this.naturesManager.getDetectedNatures();
- this.setAvailableNatures(detectedNatures);
-
- // TOOLBAR
- this.buttonGB = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, "right"));
- this.add(this.buttonGB);
-
- this.setCurrentNatureTabs([]);
- this.naturesTab = new qx.ui.tabview.TabView("top");
- this.naturesTab.addListener("changeSelected", function(e){
- this.setSelectedNatureTab(e.getData());
- this.getViewSelection().triggerEvent();
- }, this);
-
- this.basicPage = new qx.ui.tabview.Page("Basic Information");
- this.basicPage.setLayout(new qx.ui.layout.VBox(5));
-
- // GROUPBOXES
-
- this.basicGB = new qx.ui.groupbox.GroupBox("Base Informations");
- var grid = new qx.ui.layout.Grid(5,5);
- this.basicGB.setLayout(grid);
- grid.setColumnFlex(0,1);
- grid.setColumnAlign(0,"right", "middle");
- grid.setColumnFlex(1,2);
- this._initializeGroupBox(this.basicGB);
-
- this.passGB = new qx.ui.groupbox.GroupBox("Set/Modify Password");
- this.passGB.setLayout(new qx.ui.layout.VBox());
- this._initializeGroupBox(this.passGB);
-
- this.add(this.basicGB);
- this.add(this.passGB);
-
- // FIELDS
- this.usernameField = new qx.ui.form.TextField();
- this.basicGB.add(new qx.ui.basic.Label("Username"), {row:0,column:0});
- this.basicGB.add(this.usernameField, {row:0,column:1});
-
- this.rolesField = new org.argeo.ria.components.ui.MultipleComboBox();
- this.rolesField.setChoiceValues(data.ROLES_LIST);
- this.basicGB.add(new qx.ui.basic.Label("Roles"), {row:1,column:0});
- this.basicGB.add(this.rolesField, {row:1,column:1});
-
- this.passPane = new org.argeo.security.ria.components.PasswordCredentialImpl();
- this.passGB.add(this.passPane.getContainer());
-
- //this.naturesTab.add(this.basicPage);
- this.natureButtonGB = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, "right"));
- this.natureButtonGB.setMarginTop(15);
- this.add(this.natureButtonGB);
-
-
- this.add(this.naturesTab, {flex:1});
-
- this.naturesTab.setVisibility("excluded");
- this.fakePane = new qx.ui.container.Composite(new qx.ui.layout.Canvas());
- this.fakePane.setVisibility("visible");
- this.fakePane.setDecorator("tabview-pane");
- this.fakePane.setMarginTop(30);
- this.add(this.fakePane, {flex:1});
-
- title = new qx.ui.basic.Atom("User Details", "org.argeo.security.ria/preferences-users.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 title2 = new qx.ui.basic.Atom("User Natures", "org.argeo.security.ria/identity.png");
- title2.setFont(qx.bom.Font.fromString("16px sans-serif bold"));
- this.natureButtonGB.add(title2);
- this.natureButtonGB.add(new qx.ui.core.Spacer(), {flex:1});
-
-
- },
-
- saveUser : function(){
- var user = this.getCurrentUser();
- user.setName(this.usernameField.getValue());
- user.setRoles((this.rolesField.getValue()||"").split(","));
- // GO TO AND RETURN FROM SERVER
- if(user.isCreate()){
- var userExists = false;
- var req = org.argeo.security.ria.SecurityAPI.getUserExistsService(user.getName());
- req.addListener("completed", function(response){
- userExists = response.getContent().value;
- }, this);
- req.setAsynchronous(false);
- req.send();
- if(userExists){
- this.error("User already exists, choose another name!");
- return;
- }
- }
- var userService = user.getSaveService();
- userService.send();
- userService.addListener("completed", function(response){
- if(response.getContent().status && response.getContent().status == "ERROR"){
- return;
- }
- this._setGuiInCreateMode(false);
- user.load(response.getContent(), "json");
- this.partialRefreshUser(user, ["details","natures"]);
- this.setModified(false);
- this.getViewSelection().triggerEvent();
- this.fireDataEvent("savedUser", user);
- }, this);
- },
-
- _addNatureTab : function(natureClass, natureData, select){
- var crtTabs = this.getCurrentNatureTabs();
- if(qx.lang.Array.contains(crtTabs, natureClass.NATURE_TYPE)){
- this.error("There can only be one instance of a given nature type!");
- return null;
- }
- if(!this.naturesTab.isVisible()){
- if(this.fakePane) this.fakePane.setVisibility("excluded");
- this.naturesTab.setVisibility("visible");
- }
- var page = new qx.ui.tabview.Page("Nature : " + natureClass.NATURE_LABEL);
- page.setLayout(new qx.ui.layout.Dock());
- page.setUserData("NATURE_CLASS", natureClass);
- var newClass = new natureClass();
- page.add(newClass.getContainer(), {edge:"center"});