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=988e178b7503f58a02c1ec1a30b8c75709a656b6;hb=baa11e2f5b077334f51f183d352e9477cc0124ff;hp=9438113ffe9df51dc29ea7e184eb2d931777b658;hpb=98c2719d08b7d1791eb2080b4488bba810044608;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 9438113ff..988e178b7 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,6 +28,18 @@ 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", @@ -38,28 +50,62 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", 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 }, "delete_user" : { label : "Delete User", icon : "org.argeo.security.ria/list-remove.png", - shortcut : "Control+s", + shortcut : "Control+d", enabled : true, menu : "Users", toolbar : null, callback : function(e){ // Call service to delete - var crtUsers = this.getViewSelection().getNodes(); - for(var i=0;i1)); }, command : null }, @@ -72,11 +118,14 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", toolbar : null, callback : function(e){ // Call service to delete - var crtUser = this.getViewSelection().getNodes()[0]; - var userObject = this.getUsersList()[crtUser]; + 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(userObject); + 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; @@ -98,8 +147,12 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", }, usersList : { check : "Map", + apply : "_applyUsersList", event : "changeUsersList" }, + rolesList : { + check : "Array" + }, instanceId : {init:""}, instanceLabel : {init:""} }, @@ -114,7 +167,6 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", this.setView(viewPane); this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); - this.setUsersList({}); this.toolBar = new qx.ui.toolbar.ToolBar(); this.toolBarPart = new qx.ui.toolbar.Part(); this.toolBar.add(this.toolBarPart); @@ -138,9 +190,9 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", this.table.addListener("cellDblclick", function(cellEvent){ this.getCommands()["edit_user"].command.execute(); }, this); - this.addListener("changeUsersList", function(){ - this._updateTableModel(); - }, this); + + this.setRolesList([]); + this.setUsersList({}); this.setGuiMode("clear"); }, @@ -188,7 +240,19 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", 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(); @@ -200,29 +264,52 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", } this.setUsersList(usMap); }, this); - request.send(); + request.send(); }, - _updateTableModel : function(){ - var usList = this.getUsersList(); + /** + * + * @param {org.argeo.security.ria.model.User} userObject + */ + refreshUserEntry : function(userObject){ + var userName = userObject.getName(); + var data = this.tableModel.getDataAsMapArray(); + var index = 0; + var found = false; + for(index=0;index