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?";
}
);
}
+ 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");
+ }
+ }
+ );
+ }
}
/**
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();
+ }
}
/**