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;
shortcut : "Control+s",
enabled : true,
menu : "Users",
- toolbar : "userslist",
+ toolbar : null,
callback : function(e){
// Call service to delete
var crtUsers = this.getViewSelection().getNodes();
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 userObject = this.getUsersList()[crtUser];
var classObj = org.argeo.security.ria.UserEditorApplet;
var iView = org.argeo.ria.components.ViewsManager.getInstance().initIViewClass(classObj, "editor", crtUser);
- iView.load(crtUser);
+ iView.load(userObject);
},
selectionChange : function(viewName, data){
if(viewName != "users") return;
nullable:false,
check:"org.argeo.ria.components.ViewSelection"
},
+ usersList : {
+ check : "Map",
+ event : "changeUsersList"
+ },
instanceId : {init:""},
instanceLabel : {init:""}
},
*/
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.setUsersList({});
+ 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, {
this.table.addListener("cellDblclick", function(cellEvent){
this.getCommands()["edit_user"].command.execute();
}, this);
-
- this.setGuiMode("chooser");
+ this.addListener("changeUsersList", function(){
+ this._updateTableModel();
+ }, this);
+ 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);
}
},
* @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");
+
+ var request = org.argeo.security.ria.SecurityAPI.getListUsersService();
+ request.addListener("completed", function(response){
+ var jSon = response.getContent();
+ var usMap = {};
+ for(var i=0;i<jSon.length;i++){
+ var user = new org.argeo.security.ria.model.User();
+ user.load(jSon[i], "json");
+ usMap[user.getName()] = user;
+ }
+ this.setUsersList(usMap);
+ }, this);
+ request.send();
+ },
+
+ _updateTableModel : function(){
+ var usList = this.getUsersList();
+ var data = [];
+ qx.lang.Object.getValues(usList).forEach(function(usObject){
+ data.push([usObject.getName(), usObject.getRoles().join(",")]);
+ });
+ this.tableModel.setData(data);
},
applySelection : function(selectionValues, target){