]> source.dussan.org Git - archiva.git/commitdiff
start implementation of role edit view
authorOlivier Lamy <olamy@apache.org>
Wed, 28 Dec 2011 17:11:06 +0000 (17:11 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 28 Dec 2011 17:11:06 +0000 (17:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225237 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html

index 69c6792d0b7359166bf07d84316b23a916ca891e..10c37d57a7e2837972e17f7305e8037ff68eb857 100644 (file)
  */
 $(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
    */
index fcd03bacbaa157a50b6bfcef82191003905da9cd..8a856b61ac2306e557b18fe9476cfbb9bc03b692 100644 (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>
     <div id="role-edit"></div>
   </div>
 
-</script>
\ No newline at end of file
+</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>