gpt4 book ai didi

javascript - 拉力赛SDK : Retrieving all available State values for Defects

转载 作者:行者123 更新时间:2023-12-03 11:17:27 26 4
gpt4 key购买 nike

我想检索集会缺陷的所有可用状态值。以下代码适用于功能:

this.states = [];
this.stateStore = Ext.create('Ext.data.Store', {
fields: ['_ref', 'name']
});

Ext.create('Rally.data.wsapi.Store', {
model: 'State',
autoLoad: true,
filters: [
{
property: 'Enabled',
operation: '=',
value: true
},
{
property: 'TypeDef.Name',
operation: '=',
value: 'Feature'
}
],
listeners: {
load: function (store, data) {
for (var i = 0; i < data.length; i++) {
this.stateStore.add({ '_ref': data[i].data._ref, 'name': data[i].data.Name });
}
this.statesLoaded = true;
this._initialLoad();
},
scope: this
}
});

通过这种方法,我们加载功能的所有可用状态值。但是,当我将“Feature”TypeDef.Name 过滤器更改为“Defect”时,尽管定义了许多事件状态的缺陷,但我什么也没得到。有谁知道为什么会发生这种情况以及如何获得缺陷的状态值?也许缺陷使用一些其他状态,而不是像功能、suer 故事等?

最佳答案

在 WS API 中,有一个完整的 State 对象来表示 PortfolioItems 的状态。它与 Defect 或 UserStory 等工件的 State 或 ScheduleState 不同,后者只是下拉字段中的字符串值。不存在缺陷的 State.Name 这样的东西。

使用 promise ,这可能看起来像这样:

launch: function(){
this._getModel().then({
success: this._getAllowedValues,
scope:this
}).then({//...})
},

_getModel:function(){
return Rally.data.ModelFactory.getModel({
type:'Defect'
});
},

_getAllowedValues:function(model){
var deferred = Ext.create('Deft.Deferred');
var allowedStateValues = [];
model.getField('State').getAllowedValueStore().load({
callback: function(records,operation,success){
Ext.Array.each(records,function(allowedValue){
allowedStateValues.push(allowedValue.get('StringValue'));
});
if(success){
deferred.resolve(allowedStateValues);
}
else{
deferred.reject();
}

}
}) ;
return deferred.promise;
},//...

参见this example检索缺陷的优先​​级和严重性的允许值。由于这些允许空值,因此在此应用示例中删除了空值,但 State 没有空值,因此您可以跳过该步骤。

关于javascript - 拉力赛SDK : Retrieving all available State values for Defects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27275368/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com