如何在2.0rc1中获取用户故事及其所有对话?

时间:2013-09-11 09:18:07

标签: rally

如何在2.0rc1中发布用户及其所有会话

我试过

model:'HierarchicalRequirement',
fetch:[Discussion]

但这并没有回复任何对话帖子

1 个答案:

答案 0 :(得分:1)

这是打印ConvesationPosts的完整代码示例。我创建了两个Rally.data.WsapiDataStore,一个用于HierarchicalRequirement对象,另一个用于ConversationPost对象,因为当前WsapiDataStore不能有多个模型,然后在Rally.data.custom.Store

之外构建一个网格
Ext.define('CustomApp', {
    extend: 'Rally.app.TimeboxScopedApp',
    componentCls: 'app',
    scopeType: 'iteration',
    comboboxConfig: {
        fieldLabel: 'Select an Iteration:',
        labelWidth: 100,
        width: 300
    },

    addContent: function() {
        this._makeStore();
    },

    _makeStore: function(){
         Ext.create('Rally.data.WsapiDataStore', {
            model: 'HierarchicalRequirement',
            fetch: ['FormattedID','Name'],
            pageSize: 100,
            autoLoad: true,
            filters: [this.getContext().getTimeboxScope().getQueryFilter()],
            listeners: {
                load: this._onConversationPostsLoaded,
                scope: this
            }
        }); 
    },

    onScopeChange: function() {
        this._makeStore();
    },

    _onConversationPostsLoaded: function(store, data){
        this.stories = data;
        Ext.create('Rally.data.WsapiDataStore', {
            model: 'ConversationPost',
            fetch: ['Text', 'Artifact'],  
            pageSize: 100,
            autoLoad: true,
            listeners: {
                load: this._onAllDataLoaded,
                scope: this
            }
        }); 
    },
    _onAllDataLoaded: function(store, data){
        var stories = [];
        var text;
        that = this;
        if (data.length ===0) {
            this._createGrid();  
        }
        Ext.Array.each(this.stories, function(story) {
            var posts = [];
            var ref = story.get('_ref');
            Ext.Array.each(data, function(post){
                if (ref === post.get("Artifact")._ref) {
                    text = post.get("Text");
                    posts.push(text);
                }
            });
            var s  = {
                FormattedID: story.get('FormattedID'),
                _ref: story.get("_ref"),  
                Name: story.get('Name'),
                Discussions: posts
            };

            stories.push(s);
            that._createGrid(stories);
        });

     },
     _createGrid: function(stories) {
        var myStore = Ext.create('Rally.data.custom.Store', {
                data: stories,
                pageSize: 100,  
            });
        if (!this.grid) {
            this.grid = this.add({
                xtype: 'rallygrid',
                itemId: 'mygrid',
                store: myStore,
                columnCfgs: [
                    {
                        text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
                        tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
                    },
                    {
                        text: 'Name', dataIndex: 'Name'
                    },
                    {
                        text: 'Discussions', dataIndex: 'Discussions', flex: 2
                    }
                ]
            }); 
        } else {
            this.grid.reconfigure(myStore);
        }
    }
});

在此屏幕截图中,第一个故事有两个帖子,第二个故事有一个:

enter image description here