我创建了一个自定义看板。在板子里,我在卡片上有一个按钮,供人们在对项目进行代码审查时声明。单击按钮后,我想检查实时数据以确保自屏幕加载以来没有其他人声称。
如果它是一个故事,我有所有的工作,但如果它是一个缺陷,我有一个问题。所以在查看代码时,我注意到我做了 aRally.data.ModelFactory.getModel
然后 a model.load
。
所以我认为这应该更改为.getModels
并更改类型以合并故事和缺陷。但是,当我这样做时,如何正确地将其纳入搜索。我被如何加载和检查卡住了。
代码片段是:
if (this.getRecord().get("StoryStatus") == "Review Ready") {
if (this.getRecord().get("CodeReviewedBy") == '') {
content.add([{ xtype: 'button',
text: 'I will review',
scale: 'small',
listeners: {
click: function (btn, e, eOpts) {
// Verify nobody has claimed it yet !
var mod = Rally.data.ModelFactory.getModels({
types: ['HierarchicalRequirement', 'Defect'],
success: function (models) {
var model;
debugger;
if (models.Defect) model = models.Defect
else model = models.HierarchicalRequirement;
model.load(eOpts.scope.record.internalId, {
fetch: ['CodeReviewedBy'],
success: function (currentRecord) {
var currentCRB = currentRecord.get("CodeReviewedBy");
if (currentCRB) {
window.alert('While you were sitting around doing nothing, ' + currentCRB + ' already started reviewing this code');
} else {
var con = Rally.environment.getContext();
currentRecord.set("CodeReviewedBy", con.context.user._refObjectName);
currentRecord.save();
location.reload(true);
//eOpts.scope.refresh();
}
}
});
}
});
this.refresh()
},
scope: this
}
}]);
} else {
content.add([{ xtype: 'label',
html: '<b>Being reviewed by: </b>' + this.getRecord().get("CodeReviewedBy") + '<br>'
}]);
}
}