在 Rally 中查询用户故事修订 [英] Querying for User Story revisions in Rally

查看:22
本文介绍了在 Rally 中查询用户故事修订的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用与用户故事关联的 URL 检索修订日志的 JSON 对象.我已使用以下代码通过 jQuery 完成此操作,但我更愿意使用 Rally SDK 中的内置工具来完成此操作.我对 Ext.Ajax 或 Ext.data.JsonP 请求没有任何运气,尽管我认为这是正确的方法.任何帮助将不胜感激.

I would like to retrieve the JSON object for the revision log using the URL associated with the User Story. I have accomplished this with jQuery using the following code, although I would rather do it with built in tools in the Rally SDK. I haven't had any luck with Ext.Ajax or Ext.data.JsonP requests, although I feel that is the correct approach. Any help would be appreciated.

$.ajax({
    url: URL,
    dataType: 'jsonp',
    jsonp: 'jsonp',
    success: function(response) {
        $.each(response.RevisionHistory.Revisions, function(key, rev) {
            //Parse Revision Log
        });
    }
});

推荐答案

这对于 App SDK 2.0 来说相对简单.文档中的以下示例应该对您有所帮助:

This is relatively straightforward with the App SDK 2.0. The following examples in the documentation should be helpful to you:

http://developer.rallydev.com/apps/2.0p4/doc/#!/guide/appsdk_20_data_models

http://developer.rallydev.com/apps/2.0p4/doc/#!/guide/appsdk_20_data_stores

这是一个快速的小代码片段,用于获取特定故事的修订历史:

Here's a quick little code snippet to get the revision history of a specific story:

Rally.data.ModelFactory.getModel({
    type: 'UserStory',
    success: function(storyModel) {
        var storyRef = 'https://rally1.rallydev.com/slm/webservice/1.37/hierarchicalrequirement/12345.js';
        var storyID = Rally.util.Ref.getOidFromRef(storyRef);
        storyModel.load(storyID, {
            fetch: ['Name', 'FormattedID', 'Description', 'RevisionHistory', 'Revisions'],
            callback: function(story, operation) {
                if(story && story.get('RevisionHistory') && story.get('RevisionHistory').Revisions) {
                    Ext.Array.each(story.get('RevisionHistory').Revisions, function(revision) {
                        //Parse revision log
                    });
                }
            }
        });
    }
});

使用 SDK 的好处是它会根据您运行应用程序的方式自动执行 ajax 与 jsonp 请求.上面的示例非常适合单个故事.如果您想解析多个故事,您需要使用 store 而不是 model.load:

The nice thing with using the SDK is that it will automatically do ajax vs. jsonp requests depending on how you are running the app. The example above works great for a single story. If you would like to parse through multiple stories you'd want to use a store instead of model.load:

Ext.create('Rally.data.WsapiDataStore', {
    model: 'UserStory',
    autoLoad: true,
    fetch: ['Name', 'FormattedID', 'Description', 'RevisionHistory', 'Revisions'],    
    listeners: {
        load: function(store, stories) {
            Ext.Array.each(stories, function(story) { 
                if(story && story.get('RevisionHistory') && story.get('RevisionHistory').Revisions) {
                    Ext.Array.each(story.get('RevisionHistory').Revisions, function(revision) {
                        //Parse revision log
                    });
                }
            });
        }
    } 
});

这篇关于在 Rally 中查询用户故事修订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆