+ },
+ "delete_user" : {
+ label : "Delete User",
+ 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 username = this.getViewSelection().getNodes()[0];
+ var deleteService = org.argeo.security.ria.SecurityAPI.getDeleteUserService(username);
+ deleteService.addListener("completed", function(response){
+ if(response.getContent().status && response.getContent().status == "OK"){
+ this.loadUsersList();
+ }
+ }, this);
+ // Check if tab is opened before closing!
+ var editorTabPane = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("editor");
+ var iApplet = editorTabPane.contentExists(username);
+ var modal = new org.argeo.ria.components.Modal("Delete");
+ if(iApplet){
+ if(iApplet.getModified()){
+ modal.addConfirm("There are unsaved changes, are you sure you want to delete this user?");
+ modal.addListener("ok", function(e){
+ editorTabPane.closeCurrent();
+ deleteService.send();
+ }, this);
+ modal.attachAndShow();
+ }else{
+ modal.addConfirm("Are you sure you want to delete user " + username + "?");
+ modal.addListener("ok", function(e){
+ editorTabPane.closeCurrent();
+ deleteService.send();
+ }, this);
+ modal.attachAndShow();
+ }
+ }else{
+ modal.addConfirm("Are you sure you want to delete user " + username + "?");
+ modal.addListener("ok", function(e){
+ deleteService.send();
+ }, this);
+ modal.attachAndShow();
+ }
+ },
+ selectionChange : function(viewName, data){
+ if(viewName != "users") return;
+ this.setEnabled(!(data == null || !data.length || data.length>1));
+ },
+ command : null
+ },
+ "edit_user" : {
+ label : "Edit User",
+ 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 classObj = org.argeo.security.ria.UserEditorApplet;
+ 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;
+ this.setEnabled(!(data == null || !data.length || data.length > 1));
+ },
+ command : null
+ }