2012-07-13 37 views

回答

2

下面是一個同事寫的快速示例 - 它解析修訂歷史記錄集合,匹配「DESCRIPTION changed」並將結果添加到表中以供顯示。應該很容易修改,以便顯示計數而不是修訂摘要,並在您的接受準則字段也匹配。你可能想要添加IterationDropdown和其他細節。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <!-- Copyright (c) 2012 Rally Software Development Corp. All rights reserved --> 
    <html> 
    <head> 
     <title>Revision History Example</title> 
     <meta name="Name" content="App Example: Revision History" /> 
     <meta name="Version" content="2012.2" /> 
     <meta name="Vendor" content="Rally Labs" /> 
     <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.30/sdk.js?showHeader=false"></script> 
     <script type="text/javascript"> 

      function revHistoryExample() { 
       var rallyDataSource = new rally.sdk.data.RallyDataSource(
              '__WORKSPACE_OID__', 
              '__PROJECT_OID__', 
              '__PROJECT_SCOPING_UP__', 
              '__PROJECT_SCOPING_DOWN__'); 
       function itemQuery() { 
        var queryObject = { 
         key: 'stories', 
         type: 'HierarchicalRequirement', 
         fetch: 'Name,ObjectID,FormattedID,RevisionHistory,Revisions,RevisionDescription,CreationDate,LastUpdateDate,Iteration' 
         query: '(Iteration.Name = "My Iteration")', 
        }; 
        rallyDataSource.findAll(queryObject, populateTable); 
       } 

       function populateTable(results) { 
        var tableDiv = document.getElementById('aDiv'); 

       var config = { columns: 
          [{key: 'FormattedIDLink', header: 'Formatted ID', width: 100}, 
          {key: 'Name'}, 
          {key: 'RevisionDescription', header: 'Revision Description'}, 
          {key: 'CreationDate', header: 'Creation Date'}] }; 

       var table = new rally.sdk.ui.Table(config); 

       // Revision condition to match/look for within Revision history 
       var revCondition = "DESCRIPTION changed"; 

       for (i=0 ; i<results.stories.length ; i++) { 
        for (j=0 ; j<results.stories[i].RevisionHistory.Revisions.length ; j++) { 

         myStory = results.stories[i]; 
         myRevision = myStory.RevisionHistory.Revisions[j]; 

         if (myRevision.Description.indexOf(revCondition)>=0){ 

          myFormattedID = myStory.FormattedID; 
          myDescription = myRevision.Description; 

          myCreationDate = myStory.CreationDate; 
          myFormattedIDLink = new rally.sdk.ui.basic.Link(
           {item: myStory, text: results.stories[i].FormattedID} 
          ) 

          // Clobber fields on Story with info from the matching Revision for easy inclusion in table 

          results.stories[i].CreationDate = myCreationDate; 
          results.stories[i].RevisionDescription = myDescription; 
          results.stories[i].FormattedIDLink = new rally.sdk.ui.basic.Link({item:results.stories[i], text: results.stories[i].FormattedID}); 
          table.addRow(results.stories[i]); 

         } 
        } 
       } 

        table.display(tableDiv); 

       }; 
       itemQuery(); 
      } 

      rally.addOnLoad(revHistoryExample); 
     </script> 
    </head> 
    <body> 
     <div id="aDiv"></div> 
    </body> 
    </html>