From: Olivier Lamy Date: Thu, 12 Jan 2012 14:12:05 +0000 (+0000) Subject: modify user roles display binding as we will modify this we need an observable array X-Git-Tag: archiva-1.4-M3~1607 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a429442f62ad913178136ad9e2ce0cc8880886c6;p=archiva.git 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 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-edit.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-edit.html index 6a819b0d9..7e2c7dbbe 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-edit.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-edit.html @@ -90,7 +90,7 @@
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index 188a14cbe..55060ea1a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -51,6 +51,7 @@ $(function() { // admin only this.locked = ko.observable(locked); this.passwordChangeRequired = ko.observable(passwordChangeRequired); + this.assignedRoles = ko.observableArray(new Array()); this.remove = function() { if (ownerViewModel) { ownerViewModel.users.destroy(this); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js index 2035dffa1..e5f69aa2c 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js @@ -160,9 +160,12 @@ $(function() { dataType: 'json', success: function(data) { var mappedRoles = $.map(data.role, function(item) { - return mapRole(item); + var r = mapRole(item); + viewModel.user.assignedRoles.push(r); + return r; }); viewModel.roles=mappedRoles; + $("#main-content #user-edit-roles-view").attr("data-bind",'template: {name:"user_edit_roles_tmpl"}'); ko.applyBindings(viewModel,$("#user-edit-roles-view").get(0)); $("#main-content #edit_user_details_pills_headers").pills(); @@ -187,11 +190,13 @@ $(function() { $("#user-edit-roles-edit").html(smallSpinnerImg()); $.ajax("restServices/redbackServices/roleManagementService/getApplicationRoles/"+encodeURIComponent(user.username()), { type: "GET", - async: false, dataType: 'json', success: function(data) { $("#user-edit-roles-edit").html("loaded"); - + var mappedApplicationRoles = $.map(data.applicationRole, function(item) { + return mapApplicationRoles(item); + }); + $.log("applicationRoles length:"+mappedApplicationRoles.length); } } );