You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/01/04 09:50:44 UTC
svn commit: r1227082 - in
/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback:
roles.js templates/roles-tmpl.html
Author: olamy
Date: Wed Jan 4 08:50:43 2012
New Revision: 1227082
URL: http://svn.apache.org/viewvc?rev=1227082&view=rev
Log:
call REST to un/assign users to a role
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js?rev=1227082&r1=1227081&r2=1227082&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js Wed Jan 4 08:50:43 2012
@@ -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();
+ }
}
/**
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html?rev=1227082&r1=1227081&r2=1227082&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html Wed Jan 4 08:50:43 2012
@@ -143,6 +143,7 @@
<div class="ar-multiselect-column ar-multiselect-right">
<select data-bind="options: users ,optionsText: 'username',selectedOptions:selectedUsers" multiple="true" id="role-edit-affected-users"></select>
</div>
+ <button class="btn" data-bind="click: saveUsers">${$.i18n.prop('save')}</button>
</div>
</script>