Adapt to the absence of getRolesList() service...
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.ria / src / argeo-ria-lib / security / class / org / argeo / security / ria / RolesApplet.js
index da45d965bb08421cee79f69f2e5fad8c96b42fb4..676aaa3d9bbf46b55020b2dfffe0c3cae0b0eb40 100644 (file)
@@ -263,10 +263,11 @@ qx.Class.define("org.argeo.security.ria.RolesApplet",
                        return;
                }
                var uniqueValue = this._selectionToValues(selectionModel)[0];
-               var initSelection = this.rolesUsersStub[uniqueValue];
+               //var initSelection = this.rolesUsersStub[uniqueValue];
+               this.usersAppletReference.applySelection(uniqueValue, "roles");
+               var initSelection = this.usersAppletReference.getViewSelection().getNodes(); 
                this.setChooserOriginalSelection(initSelection);
                this.setChooserSelectionModified(false);
-               this.usersAppletReference.applySelection(initSelection, "username");
                this.saveButton.setEnabled(false);
        },
        
@@ -304,10 +305,21 @@ qx.Class.define("org.argeo.security.ria.RolesApplet",
         * Load a given row : the data passed must be a simple data array.
         * @param data {Element} The text xml description. 
         */
-       load : function(){              
+       load : function(){
+               // WARNING, THE USERS APPLET MUST BE LOADED!
+               var vManager = org.argeo.ria.components.ViewsManager.getInstance();
+               this.usersAppletReference = vManager.getViewPaneById("users").getContent();
+               
+               this.usersAppletReference.addListener("changeRolesList", function(event){
+                       var rolesList = event.getData();
+                       var data = [];
+                       rolesList.forEach(function(el){data.push([el]);});
+                       this.tableModel.setData(data);
+               }, this);
+               /*
                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());