*/
commands : {
init : {
+ "new_role" : {
+ label : "Create Role",
+ icon : "org.argeo.security.ria/list-add.png",
+ shortcut : "Control+n",
+ enabled : true,
+ menu : "Roles",
+ toolbar : null,
+ callback : function(e){
+ // Prompt for new name
+ },
+ command : null
+ },
+ "delete_role" : {
+ label : "Delete Role",
+ icon : "org.argeo.security.ria/list-remove.png",
+ shortcut : "Control+s",
+ enabled : true,
+ menu : "Roles",
+ toolbar : null,
+ callback : function(e){
+ // Call service to delete
+ var crtUsers = this.getViewSelection().getNodes();
+ for(var i=0;i<crtUsers.length;i++){
+ alert("Delete " + crtUsers[i]);
+ }
+ },
+ selectionChange : function(viewName, data){
+ if(viewName != "roles") return;
+ this.setEnabled(!(data == null || !data.length));
+ },
+ command : null
+ },
"edit_role" : {
label : "Edit Role",
- icon : "ria/window-close.png",
+ icon : "org.argeo.security.ria/document-properties.png",
shortcut : "Control+r",
enabled : true,
menu : "Roles",
- toolbar : "role",
+ toolbar : null,
callback : function(e){
// Call service to delete
this.setGuiMode("edit");
*/
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.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.Simple();
this.tableModel.setColumns(["Role Name"]);
this.table = new qx.ui.table.Table(this.tableModel, {
this._selectionToValues(this.table.getSelectionModel(), this.getViewSelection());
}, this);
-
this.rolesUsersStub = {"ROLE_ADMIN":["root","mbaudier"],"ROLE_USER":["mbaudier","cdujeu"]};
-
- var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(2, "right"));
- this.getView().header.setPadding(0);
- if(this.getView().headerLabel) this.getView().headerLabel.setMargin(8);
- this.getView().header.add(buttonPane, {edge:"east"});
-
- this.toggleButton = new qx.ui.form.ToggleButton("Filter", "ria/go-right.png");
+
+ this.toggleButton = new qx.ui.form.ToggleButton("Filter", "org.argeo.security.ria/go-next.png");
this.toggleButton.set({
show:"icon",
margin:2,
toolTip :new qx.ui.tooltip.ToolTip("Apply automatic filtering on Users list")
});
- buttonPane.add(this.toggleButton);
// TOGGLE THE GUI MODES
this.toggleButton.addListener("changeChecked", function(event){
this.setGuiMode(event.getData()?"filter":"clear");
}, this);
- this.saveButton = new qx.ui.form.Button("Save");
+ this.saveButton = new qx.ui.form.Button("Save", "org.argeo.security.ria/document-save.png");
this.saveButton.set({
- show:"label",
+ show:"icon",
margin:2,
toolTip :new qx.ui.tooltip.ToolTip("Save changes"),
visibility : "excluded"
});
- buttonPane.add(this.saveButton);
- this.cancelButton = new qx.ui.form.Button("Cancel");
+ this.cancelButton = new qx.ui.form.Button("Cancel", "org.argeo.security.ria/window-close.png");
this.cancelButton.set({
- show:"label",
+ show:"icon",
margin:2,
toolTip :new qx.ui.tooltip.ToolTip("Cancel changes"),
visibility : "excluded"
});
- buttonPane.add(this.cancelButton);
- var listener = function(){
+ this.saveButton.addListener("execute", function(){
+ alert("Saving changes...");
this.setGuiMode(this.initialState);
- };
- this.saveButton.addListener("execute", listener, this);
- this.cancelButton.addListener("execute", listener, this);
+ }, this);
+ this.cancelButton.addListener("execute", function(){
+ if(!this.getChooserSelectionModified()){
+ this.setGuiMode(this.initialState);
+ return;
+ }
+ var modal = new org.argeo.ria.components.Modal("Warning");
+ modal.addConfirm("There are unsaved changes!\n Are you sure you want to close?");
+ modal.addListener("ok", function(){
+ this.setGuiMode(this.initialState);
+ }, this);
+ modal.attachAndShow();
+ }, this);
this.table.addListener("cellDblclick", function(cellEvent){
this.setGuiMode("edit");
load : function(){
var data = [["ROLE_ADMIN"],["ROLE_USER"]];
this.tableModel.setData(data);
+
+ var commands = this.getCommands();
+ this.toolBarPart.add(commands["new_role"].command.getToolbarButton());
+ this.toolBarPart.add(commands["delete_role"].command.getToolbarButton());
+ this.toolBarPart.add(commands["edit_role"].command.getToolbarButton());
+ this.toolBar.addSpacer();
+ this.toolBar.add(this.toggleButton);
+ this.toolBar.add(this.saveButton);
+ this.toolBar.add(this.cancelButton);
+ this.toolBar.setShow("icon");
+
},
addScroll : function(){