+ "reload" : {
+ label : "Reload Data",
+ icon : "org.argeo.security.ria/view-refresh.png",
+ shortcut : "Control+h",
+ enabled : true,
+ menu : "Roles",
+ toolbar : "roles",
+ callback : function(e){
+ this.loadRolesList();
+ },
+ command : null
+ },
+ "new_role" : {
+ label : "Create Role",
+ icon : "org.argeo.security.ria/list-add.png",
+ shortcut : null,
+ enabled : true,
+ menu : "Roles",
+ toolbar : null,
+ callback : function(e){
+ // Prompt for new name
+ var modal = new org.argeo.ria.components.Modal();
+ modal.makePromptForm("Please enter a role name", function(roleName){
+ var service = org.argeo.security.ria.SecurityAPI.getCreateRoleService(roleName);
+ service.addListener("completed", function(response){
+ this.loadRolesList();
+ }, this);
+ service.send();
+ }, this);
+ modal.attachAndShow();
+ },
+ command : null
+ },
+ "delete_role" : {
+ label : "Delete Role",
+ icon : "org.argeo.security.ria/list-remove.png",
+ shortcut : null,
+ enabled : true,
+ menu : "Roles",
+ toolbar : null,
+ callback : function(e){
+ // Call service to delete
+ var roles = this.getViewSelection().getNodes();
+ var modal = new org.argeo.ria.components.Modal("Delete");
+ modal.addConfirm("Are you sure you want to delete the selected roles?");
+ modal.addListener("ok", function(e){
+ for(var i=0;i<roles.length;i++){
+ var service = org.argeo.security.ria.SecurityAPI.getDeleteRoleService(roles[i]);
+ service.addListener("completed", function(response){
+ this.loadRolesList();
+ }, this);
+ service.send();
+ }
+ }, this);
+ modal.attachAndShow();
+ },
+ selectionChange : function(viewName, data){
+ if(viewName != "roles") return;
+ this.setEnabled(!(data == null || !data.length));
+ },
+ command : null
+ },