在下面的代码我试图复制一个现有的功能,并为创建新对象deepcopy的功能是不是为我工作。 但没有得到新的功能对象生成formattedId
Rally.onReady(function() {
var newObj = {};
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
autoScroll: true,
launch: function() {
Ext.create('Rally.ui.dialog.ChooserDialog', {
//model: 'PortfolioItem/Feature',
//fetch: ['FormattedID','Name','UserStories'],
width: 450,
autoScroll: true,
height: 525,
title: 'Select to Copy',
pageSize: 100,
closable: false,
selectionButtonText: 'Copy',
//autoLoad: true,
artifactTypes: ['portfolioitem'],
autoShow: true,
listeners: {
artifactChosen: function(selectedRecord) {
newObj = selectedRecord;
this.onqModelRetrieved();
},
scope: this
},
storeConfig : {
filters: [
{
property: 'PortfolioItemType.Name',
operator: '!=',
value: ''
}
]
}
});
},
onqModelRetrieved: function() {
Rally.data.ModelFactory.getModel({
type: 'PortfolioItem',
success: this.onModelRetrieved,
scope: this
});
},
onModelRetrieved: function(model) {
this.model = model;
this.createFeature();
},
createFeature: function() {
var record = Ext.create(this.model, {
Name: "(Copy of) " + newObj.data.Name,
//State: 'Open',
Description: newObj.data.Description,
type: newObj.data.Workspace.type
});
record.save;
}
});
Rally.launchApp('CustomApp', {
name: 'Example'
});
});
请任何建议,有这方面的帮助..
每WS API文档,PortfolioItem是一种非可创建的类型。 有一些修改,这里是你的代码,创建了一个功能。 下面是两个例子。
我取代portfolioitem
与portfolioitem/feature
在artifactTypes
的ChooserDialog的在第一个例子。
第二个例子允许PI类型的选择,并注意在类型Rally.data.ModelFactory.getModel
在第二实例中被动态地设定。
实施例1(仅设有):
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
items:{ html:'<a href="https://help.rallydev.com/apps/2.0rc3/doc/">App SDK 2.0rc3 Docs</a>'},
_newObj : {},
launch: function() {
Ext.create('Rally.ui.dialog.ChooserDialog', {
width: 450,
autoScroll: true,
height: 525,
title: 'Select to Copy',
pageSize: 100,
closable: false,
selectionButtonText: 'Copy',
artifactTypes: ['portfolioitem/feature'],
autoShow: true,
listeners: {
artifactChosen: function(selectedRecord) {
console.log(selectedRecord.get('FormattedID') + ', ' + selectedRecord.get('Name') + ' was chosen');
this._newObj = selectedRecord;
this.onqModelRetrieved();
},
scope: this
},
});
},
onqModelRetrieved: function() {
Rally.data.ModelFactory.getModel({
type: 'PortfolioItem/Feature',
success: this.onModelRetrieved,
scope: this
});
},
onModelRetrieved: function(model) {
this.model = model;
this.createFeature();
},
createFeature: function() {
var record = Ext.create(this.model, {
Name: "(Copy of) " + this._newObj.get('Name'),
});
record.save({
callback: function(result, operation) {
if(operation.wasSuccessful()) {
console.log('created feature:', result.get('ObjectID'),result.get('FormattedID'),result.get('Name'));
}
else{
console.log("error");
}
}
});
}
});
实施例2(所有的PI的类型):
第二个例子适用于所有PI类型和artifactTypes
扩大到包括主题,主动性和特点:
artifactTypes: ['portfolioitem/theme','portfolioitem/initiative','portfolioitem/feature']
下面是代码:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
items:{ html:'<a href="https://help.rallydev.com/apps/2.0rc3/doc/">App SDK 2.0rc3 Docs</a>'},
_newObj : {},
_type : null,
launch: function() {
Ext.create('Rally.ui.dialog.ChooserDialog', {
width: 450,
autoScroll: true,
height: 525,
title: 'Select to Copy',
pageSize: 100,
closable: false,
selectionButtonText: 'Copy',
artifactTypes: ['portfolioitem/theme','portfolioitem/initiative','portfolioitem/feature'],
autoShow: true,
storeConfig:{
fetch: ['Name','PortfolioItemTypeName']
},
listeners: {
artifactChosen: function(selectedRecord) {
console.log(selectedRecord.get('FormattedID') + ', ' + selectedRecord.get('Name') + ' of type ' + selectedRecord.get('PortfolioItemTypeName') + ' was chosen');
this._type = selectedRecord.get('PortfolioItemTypeName');
this._newObj = selectedRecord;
this.onqModelRetrieved();
},
scope: this
},
});
},
onqModelRetrieved: function() {
var that = this;
that._type = 'PortfolioItem/' + that._type,
Rally.data.ModelFactory.getModel({
type: that._type,
success: this.onModelRetrieved,
scope: this
});
},
onModelRetrieved: function(model) {
this.model = model;
this.createFeature();
},
createFeature: function() {
var record = Ext.create(this.model, {
Name: "(Copy of) " + this._newObj.get('Name'),
});
record.save({
callback: function(result, operation) {
if(operation.wasSuccessful()) {
console.log('created feature:', result.get('ObjectID'),result.get('FormattedID'),result.get('Name'),result.get('PortfolioItemTypeName'));
}
else{
console.log("error");
}
}
});
}
});