]> source.dussan.org Git - archiva.git/commitdiff
fix roles grid due to new js bean mapping
authorOlivier Lamy <olamy@apache.org>
Sat, 31 Dec 2011 13:56:12 +0000 (13:56 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 31 Dec 2011 13:56:12 +0000 (13:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1226094 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 6dc455e9d27c69e5f2287b3313be658c4c673b11..58db85e30b108ec0ba935a475cffbdc79cdfadd6 100644 (file)
@@ -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();
        }
index 8f7b357e91e8e7a38e5356149a709684c937d8df..8d8c05db14c1f50753701cc0af5c91fba7f6907f 100644 (file)
@@ -8,7 +8,7 @@
       </tr>
     </thead>
     <tbody>
-      {{each role}}
+      {{each roles}}
         <tr>
           <td>${$value.name}</td>
           <td>${$value.description}</td>
   <div class="page-header">
     <h3>${$.i18n.prop('role.model.parent.roles')}</h3>
   </div>
-  {{if parentRoleNames}}
+  {{if parentRoleNames()}}
     <ul>
-      {{if $.isArray(parentRoleNames)}}
-        {{each parentRoleNames}}
+      {{if $.isArray(parentRoleNames())}}
+        {{each parentRoleNames()}}
           <li>${$value}</li>
         {{/each}}
       {{else}}
-        <li>${parentRoleNames}</li>
+        <li>${parentRoleNames()}</li>
       {{/if}}
     </ul>
   {{/if}}
-  <!--
+
   <div class="page-header">
     <h3>${$.i18n.prop('role.model.child.roles')}</h3>
   </div>
   {{else}}
     ${$.i18n.prop('role.edit.no.user.defined')}
   {{/if}}
-  -->
+
 </script>