X-Git-Url: http://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=1149cb7f27a2de90947f047d603e8688fbcbf2e5;hb=9b6a0645e8e964fd7bb04a63ddebbf2f14bd7779;hp=6a00e787cdcb9d2b82db3826169e907063761cc2;hpb=f7c73e12f9534b0b796686e207dd4b43193977fa;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 6a00e787c..1149cb7f2 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 @@ -3,7 +3,7 @@ * The only associated command is the "Close" command. */ /* ************************************************* -#asset(resource/org.argeo.security.ria/*) +#asset(org/argeo/security/ria/*) ****************************************************/ qx.Class.define("org.argeo.security.ria.UsersApplet", { @@ -28,21 +28,9 @@ 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", + icon : "org/argeo/security/ria/list-add.png", shortcut : "Control+n", enabled : true, menu : "Users", @@ -50,45 +38,82 @@ 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", + icon : "org/argeo/security/ria/list-remove.png", + 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 }, "edit_user" : { label : "Edit User", - icon : "org.argeo.security.ria/document-properties.png", + icon : "org/argeo/security/ria/document-properties.png", shortcut : "Control+u", enabled : true, menu : "Users", 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; @@ -114,8 +139,7 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", event : "changeUsersList" }, rolesList : { - check : "Array", - event : "changeRolesList" + check : "Array" }, instanceId : {init:""}, instanceLabel : {init:""} @@ -155,12 +179,13 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", this.getCommands()["edit_user"].command.execute(); }, this); + this.setRolesList([]); this.setUsersList({}); this.setGuiMode("clear"); }, _applyGuiMode : function(newMode, oldMode){ - this.table.getSelectionModel().clearSelection(); + this.table.getSelectionModel().resetSelection(); this.resetHiddenRows(); if(newMode == "filter"){ this.table.getSelectionModel().setSelectionMode(qx.ui.table.selection.Model.SINGLE_SELECTION); @@ -204,9 +229,18 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", 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.resetSelection(); var request = org.argeo.security.ria.SecurityAPI.getListUsersService(); request.addListener("completed", function(response){ var jSon = response.getContent(); @@ -221,21 +255,40 @@ qx.Class.define("org.argeo.security.ria.UsersApplet", request.send(); }, + /** + * + * @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