start implementation of role edit view

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-12-28 17:11:06 +00:00
parent ad203f9969
commit 46cc43e9bc
2 changed files with 88 additions and 3 deletions

View File

@ -18,9 +18,14 @@
*/
$(function() {
role = function(name,description){
role = function(name,description,permissions){
this.name = name;
this.description = description;
this.permissions=permissions;
}
permission = function(){
}
displayRolesGrid = function(){
@ -29,7 +34,6 @@ $(function() {
$.ajax("restServices/redbackServices/roleManagementService/allRoles",
{
type: "GET",
async: false,
dataType: 'json',
success: function(data) {
var roles = $.map(data.role, function(item) {
@ -38,12 +42,28 @@ $(function() {
$("#main-content").html($("#rolesTabs").tmpl());
$("#main-content #roles-view-tabs-content #roles-view").html($("#rolesGrid").tmpl(data));
$("#roles-view-tabs").tabs();
activateRolesGridTab();
}
}
);
}
editRole = function(roleName){
$.log("edit role:"+roleName);
$.ajax("restServices/redbackServices/roleManagementService/getRole/"+roleName,
{
type: "GET",
dataType: 'json',
success: function(data) {
var role = mapRole(data.role);
$("#main-content #roles-view-tabs-content #role-edit").html($("#editRoleTab").tmpl(data.role));
activateRoleEditTab();
}
}
);
}
/**
* @param data Role response from redback rest api
*/

View File

@ -4,6 +4,7 @@
<tr>
<th>${$.i18n.prop('roles.name')}</th>
<th>${$.i18n.prop('roles.description')}</th>
<th>${$.i18n.prop('edit')}</th>
</tr>
</thead>
<tbody>
@ -11,6 +12,9 @@
<tr>
<td>${$value.name}</td>
<td>${$value.description}</td>
<td>
<a href="#" onclick="javascript:editRole(encodeURI('${$value.name}'));">${$.i18n.prop('edit')}</a>
</td>
</tr>
{{/each}}
</tbody>
@ -36,4 +40,65 @@
<div id="role-edit"></div>
</div>
</script>
</script>
<script id="editRoleTab" type="text/x-jquery-tmpl">
<div class="page-header">
<h3>${$.i18n.prop('role.edit')}</h3>
</div>
<table class="bordered-table" id="editRoleTable">
<tbody>
<tr>
<td>${$.i18n.prop('role.edit.name')}:</td>
<td>${name}</td>
</tr>
<tr>
<td>${$.i18n.prop('role.edit.description')}:</td>
<td>${description}</td>
</tr>
</tbody>
</table>
<div class="page-header">
<h3>${$.i18n.prop('role.parents')}</h3>
</div>
<ul>
{{each parentRoleNames}}
<li>${$value}</li>
{{/each}}
</ul>
<div class="page-header">
<h3>${$.i18n.prop('role.childs')}</h3>
</div>
<ul>
{{each childRoleNames}}
<li>${$value}</li>
{{/each}}
</ul>
{{if permissions}}
<div class="page-header">
<h3>${$.i18n.prop('role.permissions')}</h3>
</div>
<table class="bordered-table zebra-striped" id="rolePermissionsTable">
<thead>
<tr>
<th>${$.i18n.prop('role.permission.name')}</th>
<th>${$.i18n.prop('role.permission.operation.name')}</th>
<th>${$.i18n.prop('role.permission.resource.')}</th>
</tr>
</thead>
<tbody>
{{each permissions}}
<tr>
<td>${$value.name}</td>
<td>${$value.operation.name}</td>
<td>${$value.resource.identifier}</td>
</tr>
{{/each}}
</tbody>
</table>
{{/if}}
</script>