如何使用自定义网格在缺陷套件中显示缺陷

时间:2014-01-03 06:16:15

标签: rally

我有一个场景,我想创建一个自定义网格,显示项目中链接到特定缺陷套件的所有缺陷。

鉴于关系是从缺陷套件到缺陷(例如缺陷套件有缺陷集合),如何在自定义网格中创建自定义查询,显示与该缺陷套件相关的所有缺陷?

1 个答案:

答案 0 :(得分:0)

在WS API的v2.0中,出于性能原因,我们删除了在同一响应中返回子集合的功能。在v2.0中,获取集合将返回一个带有count的对象和从中获取集合的url。这意味着当我们查询DefectSuite对象时,不会返回其缺陷集合。

对于自定义网格,当您在对象下拉列表中选择DefectSuite时,自定义网格上的列中无法使用Defects的Defects集合。

Here is an example自定义应用,显示包含相关缺陷的缺陷套件网格。 DefectSuites按发布过滤。您可以将this html file复制/粘贴到Rally中的自定义页面中。

js文件:

Ext.define('CustomApp', {
    extend: 'Rally.app.TimeboxScopedApp',
    componentCls: 'app',
    scopeType: 'release',
    addContent: function() {
        this._makeStore();
    },
   onScopeChange: function() {
        console.log('onScopeChange');
        this._makeStore();
    },
_makeStore: function(){
        Ext.create('Rally.data.WsapiDataStore', {
                model: 'DefectSuite',
                fetch: ['FormattedID', 'Defects', 'DefectStatus'],  
                pageSize: 100,
                autoLoad: true,
                filters: [this.getContext().getTimeboxScope().getQueryFilter()],
                listeners: {
                    load: this._onDefectSuitesLoaded,
                    scope: this
                }
            }); 
    },
     _onDefectSuitesLoaded: function(store, data){
        var defectSuites = [];
        var pendingDefects = data.length;
         console.log(data.length);
         if (data.length ===0) {
            this._createDefectSuitesGrid(defectSuites);  
         }
         Ext.Array.each(data, function(defectsuite){ 
            var ds  = {
                FormattedID: defectsuite.get('FormattedID'),   
                _ref: defectsuite.get('_ref'),  
                DefectStatus: defectsuite.get('DefectStatus'),
                DefectCount: defectsuite.get('Defects').Count,
                Defects: []
            };
            var defects = defectsuite.getCollection('Defects');
            defects.load({
                                fetch: ['FormattedID'],
                                callback: function(records, operation, success){
                                    Ext.Array.each(records, function(defect){
                                        ds.Defects.push({_ref: defect.get('_ref'),
                                                        FormattedID: defect.get('FormattedID')
                                                    });
                                    }, this);
                                    --pendingDefects;
                                    if (pendingDefects === 0) {
                                        this._createDefectSuitesGrid(defectSuites);
                                    }
                                },
                                scope: this
                            });
            defectSuites.push(ds);
     },this);
 },

      _createDefectSuitesGrid: function(defectsuites) {
        var defectSuiteStore = Ext.create('Rally.data.custom.Store', {
                data: defectsuites,
                pageSize: 100,  
            });
        if (!this.down('#defectsuitegrid')) {
         this.grid = this.add({
            xtype: 'rallygrid',
            itemId: 'defectsuitegrid',
            store: defectSuiteStore,
            columnCfgs: [
                {
                   text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
                    tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
                },
                {
                    text: 'Defect Count', dataIndex: 'DefectCount',
                },
                {
                    text: 'Defect Status', dataIndex: 'DefectStatus',flex:1
                },
                {
                    text: 'Defects', dataIndex: 'Defects',flex:1, 
                    renderer: function(value) {
                        var html = [];
                        Ext.Array.each(value, function(defect){
                            html.push('<a href="' + Rally.nav.Manager.getDetailUrl(defect) + '">' + defect.FormattedID + '</a>')
                        });
                        return html.join(', ');
                    }
                }
            ]
        });
         }else{
            this.grid.reconfigure(defectSuiteStore);
         }
    }
});