modify user roles display binding as we will modify this we need an observable array

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1230552 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-01-12 14:12:05 +00:00
parent 9c6d1fb950
commit a429442f62
3 changed files with 10 additions and 4 deletions

View File

@ -90,7 +90,7 @@
</div> </div>
<div> <div>
<ul> <ul>
{{each $data.roles}} {{each $data.user.assignedRoles}}
<li>${$value.name}</li> <li>${$value.name}</li>
{{/each}} {{/each}}
</ul> </ul>

View File

@ -51,6 +51,7 @@ $(function() {
// admin only // admin only
this.locked = ko.observable(locked); this.locked = ko.observable(locked);
this.passwordChangeRequired = ko.observable(passwordChangeRequired); this.passwordChangeRequired = ko.observable(passwordChangeRequired);
this.assignedRoles = ko.observableArray(new Array());
this.remove = function() { this.remove = function() {
if (ownerViewModel) { if (ownerViewModel) {
ownerViewModel.users.destroy(this); ownerViewModel.users.destroy(this);

View File

@ -160,9 +160,12 @@ $(function() {
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
var mappedRoles = $.map(data.role, function(item) { var mappedRoles = $.map(data.role, function(item) {
return mapRole(item); var r = mapRole(item);
viewModel.user.assignedRoles.push(r);
return r;
}); });
viewModel.roles=mappedRoles; viewModel.roles=mappedRoles;
$("#main-content #user-edit-roles-view").attr("data-bind",'template: {name:"user_edit_roles_tmpl"}'); $("#main-content #user-edit-roles-view").attr("data-bind",'template: {name:"user_edit_roles_tmpl"}');
ko.applyBindings(viewModel,$("#user-edit-roles-view").get(0)); ko.applyBindings(viewModel,$("#user-edit-roles-view").get(0));
$("#main-content #edit_user_details_pills_headers").pills(); $("#main-content #edit_user_details_pills_headers").pills();
@ -187,11 +190,13 @@ $(function() {
$("#user-edit-roles-edit").html(smallSpinnerImg()); $("#user-edit-roles-edit").html(smallSpinnerImg());
$.ajax("restServices/redbackServices/roleManagementService/getApplicationRoles/"+encodeURIComponent(user.username()), { $.ajax("restServices/redbackServices/roleManagementService/getApplicationRoles/"+encodeURIComponent(user.username()), {
type: "GET", type: "GET",
async: false,
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
$("#user-edit-roles-edit").html("loaded"); $("#user-edit-roles-edit").html("loaded");
var mappedApplicationRoles = $.map(data.applicationRole, function(item) {
return mapApplicationRoles(item);
});
$.log("applicationRoles length:"+mappedApplicationRoles.length);
} }
} }
); );