You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2011/12/28 18:11:06 UTC

svn commit: r1225237 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback: roles.js templates/roles-tmpl.html

Author: olamy
Date: Wed Dec 28 17:11:06 2011
New Revision: 1225237

URL: http://svn.apache.org/viewvc?rev=1225237&view=rev
Log:
start implementation of role edit view

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

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js?rev=1225237&r1=1225236&r2=1225237&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js Wed Dec 28 17:11:06 2011
@@ -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
    */

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html?rev=1225237&r1=1225236&r2=1225237&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html Wed Dec 28 17:11:06 2011
@@ -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>
\ 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>