2016-09-22 38 views
1

当我使用Rally.data.WsapiDataStore查询用户素材时,我可以检索Iteration.StartDate和Iteration.EndDate。但是,当我使用.getCollection('Predecessors')加载集合时,迭代名称被加载,但StartDate和EndDate未被填充。应用程序代码写入控制台以检查Iteration对象。Iteration.StartDate不可用

<!DOCTYPE html> 
<html> 
<head> 
    <title>Rally</title> 

    <script type="text/javascript" src="/apps/2.0rc3/sdk.js"></script> 

    <script type="text/javascript"> 
     Rally.onReady(function() { 
       Ext.define('CustomApp', { 
    extend: 'Rally.app.App', 

    launch: function() { 
    MyApp = this; 

    MyApp.globalContext = this.getContext().getDataContext(); 
    MyApp.PredecessorSearch = []; 

    Ext.getBody().mask('Loading...'); 

    // Update the filter 
    var filter = Ext.create('Rally.data.QueryFilter', { 
     property: 'DirectChildrenCount', 
     operator: '=', 
     value: '0' 
    }); 

    var filter2 = Ext.create('Rally.data.QueryFilter', { 
     property: 'ScheduleState', 
     operator: '!=', 
     value: 'Accepted' 
    }); 

    filter = filter.and(filter2); 

    Ext.create('Rally.data.WsapiDataStore', { 
     autoLoad: true, 
     limit: Infinity, 
     model: 'UserStory', 
     context: MyApp.globalContext, 
     fetch: ['Feature', 'Parent', 'Children', 
       'FormattedID', 'Name', 
       'ScheduleState', 'c_DevKanban', 
       'Release', 'Iteration', 'StartDate', 'EndDate', 
       'Blocked', 'BlockedReason', 
       'Predecessors', 
       'Owner','ObjectID' ], 
     filters: [ filter ], 
     sorters: [{ 
     property: 'Rank', 
     direction: 'ASC' 
     }], 
     listeners: { 
     load: function (store, records) { 
      Ext.each(records, function(record) { 
      record.data.PredecessorData = []; 

      console.log("Story " + record.data.FormattedID, record.data.Iteration); 

      // Look for predecessors 
      //console.log(record.data.Predecessors); 
      if (record.data.Predecessors && 
       record.data.Predecessors.Count > 0) { 
       MyApp._loadPredecessorsInStory(record); 
      } 
      // End of look for associated predecessors 
      }); 

      var wait = function(condFunc, readyFunc, checkInterval) { 
      var checkFunc = function() { 
       if(condFunc()) { readyFunc(); } 
       else    { setTimeout(checkFunc, checkInterval); } 
      }; 
      checkFunc(); 
      }; 

      MyApp.PredecessorSearch.push('END'); 

      wait(
      function() { 
       return (MyApp.PredecessorSearch[0] == 'END'); 
      }, 
      function() { 
       Ext.getBody().unmask(); 
      }, 
      1000 
     ); 
     } 
     } 
    }); 
    }, 

    _loadPredecessorsInStory: function (userStory) { 
    // Add this user story to the end of the list 
    MyApp.PredecessorSearch.push(userStory.data.FormattedID); 

    userStory.getCollection('Predecessors').load({ 
     scope: this, 
     autoLoad: true, 
     limit: Infinity, 
     context: MyApp.globalContext, 
     fetch: ['Requirement', 
       'FormattedID', 'Name', 
       'State', 'ScheduleState', 'c_DevKanban', 
       'Release', 'Iteration', 'StartDate', 'EndDate', 
       'Blocked', 'BlockedReason', 
       'Owner','ObjectID' ], 
     filters: [ { 
     property: 'ScheduleState', 
     operator: '!=', 
     value: 'Accepted' } 
     ], 
     callback: function(records, operation, success){ 
     Ext.Array.each(records, function(record){ 
      console.log("Predecessor " + record.data.FormattedID, record.data.Iteration); 
     }); 

     // Remove this user story from the front of the list 
     MyApp._removeElement(MyApp.PredecessorSearch, userStory.data.FormattedID); 
     } 
    }); 
    }, 

    _removeElement: function(array, element) { 
    for(var i = array.length - 1; i >= 0; i--) { 
     if(array[i] === element) { 
     array.splice(i, 1); 
     return true; 
     } 
    } 

    return false; 
    } 
}); 


      Rally.launchApp('CustomApp', { 
       name:"Rally", 
       parentRepos:"" 
      }); 

     }); 
    </script> 


</head> 
<body> 
</body> 
</html> 

回答

1

我似乎记得这是2.0rc3版本的getCollection方法中的一个bug。如果你在配置参数中传递你的提取而不是传递它来加载?

userStory.getCollection('Predecessors', { 
    fetch: ['Iteration', 'StartDate', 'EndDate', etc...] 
}).load()... 

您也可以尝试升级到最新的SDK版本 - 2.0或最近的2.1 ...

+0

这已经工作,将读取从载入移到getCollection。谢谢,凯尔 –

0

我很困惑,你是否期待“起始日期”和“结束日期”字段如在要填充的fetch []中定义的,或者您是否期待填充Iteration.EndDate和Iteration.StartDate。第一个不存在于用户故事中(它是getCollection要返回的类型),它们只存在于Iteration类型上。

我认为KyleM指的是为一个类型提取的默认字段,除非你用另一个列表覆盖列表 - 我不知道如何做,当提取的项目是getCollection的一部分(这将采取您指定的配置,而不是将它传递到迭代数据的获取)