Question

I created a custom application in Rally that is a modified version of the Catalog App Kanban Board. I took the StandardCardRendered and extended it by adding fields, changing formatting, and hiding objects. I'm trying to duplicate the "Days Since Last Column Move" code and my RevisionHistory object appears to be empty, so I'm really just calculating the "Days Since Story Created". How do I correctly calculate the "Days Since List Column Move"?

All my calculation logic is stored in the this._getColumnAgeDays function and I included CreationDate and RevisionHistory in my Fetch, but these fields weren't necessary in the code for Catalog App Kanban Board. Below is a sample of the code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 <html> 
 <head> 
    <title>App Example: Test</title> 
    <meta name="Name" content="App Example: Test" /> 
    <meta name="Vendor" content="Test" /> 
    <script type="text/javascript" src="/apps/1.26/sdk.js"></script> 
    <script type="text/javascript"> 

        var EnhancedCardRenderer = function(column, item, options)  
        { 
            rally.sdk.ui.cardboard.BasicCardRenderer.call(this, column, item, options); 
            var that = this; 

            this.getCardBody = function()  
            { 
                var card = document.createElement("div"); 
                card.innerHTML = item.Name; 

                // Add card footer. 
                var CardFooterDiv = document.createElement("div"); 
                dojo.addClass(CardFooterDiv, 'footerCardBorder'); 
                dojo.addClass(CardFooterDiv, 'footerCardFormat'); 
                var DaysMessage = "Days: " + that._getColumnAgeDays(); 
                CardFooterDiv.appendChild(document.createTextNode(DaysMessage)); 
                card.appendChild(CardFooterDiv); 

                return card; 
            }; 

            this._getColumnAgeDays = function()  
            { 
                var daysOld = 0; 

                function getLastStateChange() { 
                    var revisions = item.RevisionHistory.Revisions; 
                    var lastStateChangeDate = ""; 

                    rally.forEach(revisions, function(revision) { 
                        if (lastStateChangeDate.length === 0) { 
                            var attr = options.attribute.toUpperCase(); 

                            if (revision.Description.indexOf(attr + " changed from") !== -1) { 
                                lastStateChangeDate = revision.CreationDate; 
                            } 
                            if (revision.Description.indexOf(attr + " added") !== -1) { 
                                lastStateChangeDate = revision.CreationDate; 
                            } 
                        } 
                    }); 
                    return lastStateChangeDate || item.CreationDate; 
                } 

                var lastStateDate = getLastStateChange(); 

                var lastUpdateDate = rally.sdk.util.DateTime.fromIsoString(lastStateDate); 
                return rally.sdk.util.DateTime.getDifference(new Date(), lastUpdateDate, "day"); 
            }; 

        }; 


     function onLoad() { 
        var cardboard; 

       var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__', 
 '__PROJECT_OID__', 
 '__PROJECT_SCOPING_UP__', 
 '__PROJECT_SCOPING_DOWN__'); 
        var cardboardConfig = { 
          attribute: "Kanban", 


     cardRenderer:EnhancedCardRenderer, 
          fetch:"Name,FormattedID,Owner,ObjectID,CreationDate,RevisionHistory,Revisions" 
          }; 
    cardboardConfig.cardOptions = { attribute: cardboardConfig.attribute };      
    cardboard = new rally.sdk.ui.CardBoard(cardboardConfig, rallyDataSource); 
    cardboard.display(dojo.body()); 
  } 
      rally.addOnLoad(onLoad); 

   </script> 
    <style type="text/css"> 


    </style> 
 </head> 
 <body> 
 </body> 
 </html>
Was it helpful?

Solution

You'll want to add Revisions to your fetch. The reason this works in the Kanban app is because the CardBoard component on which it is built is doing this behind the scenes automatically.

Note that fetching Revision History/Revisions can be an expensive operation- that is the reason the Kanban does the initial data load first and then once the board is rendered makes secondary requests to gather aging data from the revision history.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top