From f922429f2f9813e4455f90a3abbff2115b60932b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 4 Jan 2012 08:50:43 +0000 Subject: [PATCH] call REST to un/assign users to a role git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1227082 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/redback/roles.js | 23 +++++++++++++++++++ .../js/redback/templates/roles-tmpl.html | 1 + 2 files changed, 24 insertions(+) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js index c72a93a0e..ec1b22e72 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js @@ -29,6 +29,7 @@ $(function() { this.permissions = ko.observableArray(permissions);//read only // when editing a role other users not assign to this role are populated this.otherUsers = ko.observableArray(otherUsers); + this.removedUsers=ko.observableArray([]); this.updateDescription=function(){ var url = "restServices/redbackServices/roleManagementService/updateRoleDescription?"; @@ -49,6 +50,23 @@ $(function() { } ); } + this.updateUsers=function(){ + var url = "restServices/redbackServices/roleManagementService/updateRoleUsers"; + $.ajax(url, + { + type: "POST", + dataType: 'json', + contentType: 'application/json', + data: "{\"role\": " + ko.toJSON(this)+"}", + success: function(data) { + displaySuccessMessage($.i18n.prop("role.users.updated",this.name)); + }, + error: function(data){ + displayErrorMessage("error updating users role"); + } + } + ); + } } /** @@ -145,13 +163,18 @@ $(function() { var added = currentRole.users.removeAll(selectedUsers()); for (var i = 0; i < added.length; i++) { currentRole.otherUsers.push(added[i]); + currentRole.removedUsers.push(added[i]); } selectedUsers([]); + } saveRoleDescription=function(){ $.log("saveRoleDescription:"+currentRole.description()); currentRole.updateDescription(); } + saveUsers=function(){ + currentRole.updateUsers(); + } } /** diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html index 103443ba8..79e3841de 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html @@ -143,6 +143,7 @@
+ -- 2.39.5