X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.ria%2Fsrc%2Fargeo-ria-lib%2Fsecurity%2Fclass%2Forg%2Fargeo%2Fsecurity%2Fria%2FUsersApplet.js;h=b107a3ee4a6dc82b368cebd138bff9c1f24b45b0;hb=b9f0dc6d3192adcbd4e9de8053b087e36759820e;hp=f4765628f9f7e6c573d92363713bf887443a7074;hpb=f0037ce21f65a9ae5fb87cb706398a83f5b42880;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js index f4765628f..b107a3ee4 100644 --- a/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js +++ b/security/runtime/org.argeo.security.ria/src/argeo-ria-lib/security/class/org/argeo/security/ria/UsersApplet.js @@ -28,18 +28,34 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", */ commands : { init : { + "load_users" : { + label : "Reload Users", + icon : "org.argeo.security.ria/view-refresh.png", + shortcut : "Control+h", + enabled : true, + menu : "Users", + toolbar : "users", + callback : function(e){ + this.loadUsersList(); + }, + command : null + }, "new_user" : { label : "New User", icon : "org.argeo.security.ria/list-add.png", shortcut : "Control+n", enabled : true, menu : "Users", - toolbar : "userslist", + toolbar : null, callback : function(e){ // Call service to delete var classObj = org.argeo.security.ria.UserEditorApplet; - var iView = org.argeo.ria.components.ViewsManager.getInstance().initIViewClass(classObj, "editor"); + var initData = {USER:null,ROLES_LIST:this.getRolesList()}; + var iView = org.argeo.ria.components.ViewsManager.getInstance().initIViewClass(classObj, "editor", initData); iView.load(); + iView.addListener("savedUser", function(e){ + this.refreshUserEntry(e.getData()); + }, this); }, command : null }, @@ -49,17 +65,47 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", shortcut : "Control+s", enabled : true, menu : "Users", - toolbar : "userslist", + toolbar : null, callback : function(e){ // Call service to delete - var crtUsers = this.getViewSelection().getNodes(); - for(var i=0;i1)); }, command : null }, @@ -69,13 +115,17 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", shortcut : "Control+u", enabled : true, menu : "Users", - toolbar : "userslist", + toolbar : null, callback : function(e){ // Call service to delete - var crtUser = this.getViewSelection().getNodes()[0]; + var crtUser = this.getViewSelection().getNodes()[0]; var classObj = org.argeo.security.ria.UserEditorApplet; - var iView = org.argeo.ria.components.ViewsManager.getInstance().initIViewClass(classObj, "editor", crtUser); - iView.load(crtUser); + var initData = {USER:crtUser,ROLES_LIST:this.getRolesList()}; + var iView = org.argeo.ria.components.ViewsManager.getInstance().initIViewClass(classObj, "editor", initData); + iView.load(crtUser); + iView.addListener("savedUser", function(e){ + this.refreshUserEntry(e.getData()); + }, this); }, selectionChange : function(viewName, data){ if(viewName != "users") return; @@ -95,6 +145,14 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", nullable:false, check:"org.argeo.ria.components.ViewSelection" }, + usersList : { + check : "Map", + apply : "_applyUsersList", + event : "changeUsersList" + }, + rolesList : { + check : "Array" + }, instanceId : {init:""}, instanceLabel : {init:""} }, @@ -107,7 +165,13 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", */ init : function(viewPane){ this.setView(viewPane); - this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); + this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); + + this.toolBar = new qx.ui.toolbar.ToolBar(); + this.toolBarPart = new qx.ui.toolbar.Part(); + this.toolBar.add(this.toolBarPart); + viewPane.add(this.toolBar); + this.tableModel = new qx.ui.table.model.Filtered(); this.tableModel.setColumns(["username", "roles"]); this.table = new qx.ui.table.Table(this.tableModel, { @@ -126,19 +190,21 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", this.table.addListener("cellDblclick", function(cellEvent){ this.getCommands()["edit_user"].command.execute(); }, this); - - this.setGuiMode("chooser"); + + this.setRolesList([]); + this.setUsersList({}); + this.setGuiMode("clear"); }, _applyGuiMode : function(newMode, oldMode){ this.table.getSelectionModel().clearSelection(); this.resetHiddenRows(); if(newMode == "filter"){ - this.table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_INTERVAL_SELECTION); + this.table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION); }else if(newMode == "chooser"){ this.table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.MULTIPLE_INTERVAL_SELECTION_TOGGLE); }else if(newMode == "clear"){ - this.table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_INTERVAL_SELECTION); + this.table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION); } }, @@ -169,21 +235,81 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", * @param data {Element} The text xml description. */ load : function(){ - var data = [["root", "ROLE_ADMIN"], ["mbaudier", "ROLE_ADMIN,ROLE_USER"], ["cdujeu","ROLE_USER"], ["anonymous", ""]]; - this.tableModel.setData(data); + var commands = this.getCommands(); + this.toolBarPart.add(commands["new_user"].command.getToolbarButton()); + this.toolBarPart.add(commands["delete_user"].command.getToolbarButton()); + this.toolBarPart.add(commands["edit_user"].command.getToolbarButton()); + this.toolBar.setShow("icon"); + this.loadUsersList(); + + var rolesApplet = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("roles").getContent(); + rolesApplet.addListener("changeRolesList", function(e){ + this.setRolesList(e.getData()); + this.loadUsersList(); + }, this); + + }, + + loadUsersList : function(){ + var selectionModel = this.table.getSelectionModel(); + selectionModel.clearSelection(); + var request = org.argeo.security.ria.SecurityAPI.getListUsersService(); + request.addListener("completed", function(response){ + var jSon = response.getContent(); + var usMap = {}; + for(var i=0;i