From 4214210c88a3fc357af480144299976104b6dec1 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 31 Dec 2011 13:56:12 +0000 Subject: [PATCH] fix roles grid due to new js bean mapping git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1226094 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/redback/roles.js | 25 ++++++++++++++++++- .../js/redback/templates/roles-tmpl.html | 14 +++++------ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js index 6dc455e9d..58db85e30 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js @@ -54,6 +54,28 @@ $(function() { } } + /** + * view model used for roles grid + */ + rolesViewModel=function() { + this.roles = ko.observableArray([]); + + this.loadRoles = function() { + $.ajax("restServices/redbackServices/roleManagementService/allRoles", { + type: "GET", + async: false, + dataType: 'json', + success: function(data) { + var mappedRoles = $.map(data.role, function(item) { + return mapRole(item); + }); + self.roles(mappedRoles); + } + } + ); + }; + + } displayRolesGrid = function(){ @@ -69,7 +91,8 @@ $(function() { }); $.log(ko.toJSON(roles)); $("#main-content").html($("#rolesTabs").tmpl()); - $("#main-content #roles-view-tabs-content #roles-view").html($("#rolesGrid").tmpl(roles)); + var data = {roles: roles}; + $("#main-content #roles-view-tabs-content #roles-view").html($("#rolesGrid").tmpl(data)); $("#roles-view-tabs").tabs(); activateRolesGridTab(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html index 8f7b357e9..8d8c05db1 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html @@ -8,7 +8,7 @@ - {{each role}} + {{each roles}} ${$value.name} ${$value.description} @@ -69,18 +69,18 @@ - {{if parentRoleNames}} + {{if parentRoleNames()}} {{/if}} - + -- 2.39.5