mirror of https://github.com/apache/archiva.git
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
This commit is contained in:
parent
c7e91a6139
commit
f922429f2f
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue