Skip to content

Commit 46f3f68

Browse files
authored
Merge pull request #32 from RallyTechServices/types
show all user listable types
2 parents 0ea66c1 + de4b28c commit 46f3f68

File tree

5 files changed

+115
-63
lines changed

5 files changed

+115
-63
lines changed

deploy/Ugly.txt

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"nodemonConfig": {
2727
"watch": [
28-
"src/*", "templates/*"
28+
"src/*", "templates/*", "*.json"
2929
],
3030
"verbose": true
3131
}

src/javascript/app.js

Lines changed: 78 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ Ext.define("custom-grid-with-deep-export", {
168168
});
169169
},
170170
_getExportMenuItems: function(){
171+
var result = [];
171172
this.logger.log('_getExportMenuItems', this.modelNames[0]);
172-
173-
if (this.modelNames[0].toLowerCase() === 'hierarchicalrequirement'){
174-
return [{
173+
var currentModel = this.modelNames[0].toLowerCase();
174+
if (currentModel === 'hierarchicalrequirement'){
175+
result = [{
175176
text: 'Export User Stories...',
176177
handler: this._export,
177178
scope: this,
@@ -187,40 +188,72 @@ Ext.define("custom-grid-with-deep-export", {
187188
scope: this,
188189
childModels: ['hierarchicalrequirement','task','defect','testcase']
189190
}];
190-
}
191-
192-
//If its not a story, then its a PI
193-
var idx = _.indexOf(this.getPortfolioItemTypeNames(), this.modelNames[0].toLowerCase());
194-
var childModels = [];
195-
if (idx > 0){
196-
for (var i = idx; i > 0; i--){
197-
childModels.push(this.getPortfolioItemTypeNames()[i-1].toLowerCase());
191+
} else if (currentModel.startsWith("portfolioitem")) {
192+
var idx = _.indexOf(this.getPortfolioItemTypeNames(), currentModel);
193+
var childModels = [];
194+
if (idx > 0){
195+
for (var i = idx; i > 0; i--){
196+
childModels.push(this.getPortfolioItemTypeNames()[i-1].toLowerCase());
197+
}
198198
}
199+
200+
result = [{
201+
text: 'Export Portfolio Items...',
202+
handler: this._export,
203+
scope: this,
204+
childModels: childModels
205+
},{
206+
text: 'Export Portfolio Items and User Stories...',
207+
handler: this._export,
208+
scope: this,
209+
includeStories: true,
210+
includeTasks: false,
211+
childModels: childModels.concat(['hierarchicalrequirement'])
212+
},{
213+
text: 'Export Portfolio Items, User Stories and Tasks...',
214+
handler: this._export,
215+
scope: this,
216+
childModels: childModels.concat(['hierarchicalrequirement','task'])
217+
},{
218+
text: 'Export Portfolio Items and Child Items...',
219+
handler: this._export,
220+
scope: this,
221+
childModels: childModels.concat(['hierarchicalrequirement','defect','testcase'])
222+
}];
223+
} else if (currentModel == 'defect') {
224+
result = [{
225+
text: 'Export Defects...',
226+
handler: this._export,
227+
scope: this,
228+
childModels: []
229+
},{
230+
text: 'Export Defects and Child Items...',
231+
handler: this._export,
232+
scope: this,
233+
childModels: ['defect', 'task', 'testcase']
234+
}];
235+
} else if (currentModel == 'testcase') {
236+
result = [{
237+
text: 'Export Test Cases...',
238+
handler: this._export,
239+
scope: this,
240+
childModels: []
241+
},{
242+
text: 'Export Test Cases and Child Items...',
243+
handler: this._export,
244+
scope: this,
245+
childModels: ['defect', 'task', 'testcase']
246+
}];
247+
} else {
248+
result = [{
249+
text: 'Export to CSV...',
250+
handler: this._export,
251+
scope: this,
252+
childModels: []
253+
}];
199254
}
200-
201-
return [{
202-
text: 'Export Portfolio Items...',
203-
handler: this._export,
204-
scope: this,
205-
childModels: childModels
206-
},{
207-
text: 'Export Portfolio Items and User Stories...',
208-
handler: this._export,
209-
scope: this,
210-
includeStories: true,
211-
includeTasks: false,
212-
childModels: childModels.concat(['hierarchicalrequirement'])
213-
},{
214-
text: 'Export Portfolio Items, User Stories and Tasks...',
215-
handler: this._export,
216-
scope: this,
217-
childModels: childModels.concat(['hierarchicalrequirement','task'])
218-
},{
219-
text: 'Export Portfolio Items and Child Items...',
220-
handler: this._export,
221-
scope: this,
222-
childModels: childModels.concat(['hierarchicalrequirement','defect','testcase'])
223-
}];
255+
256+
return result;
224257
},
225258
getPortfolioItemTypeNames: function(){
226259
return _.pluck(this.portfolioItemTypes, 'typePath');
@@ -245,7 +278,15 @@ Ext.define("custom-grid-with-deep-export", {
245278
_getExportColumns: function(){
246279
var grid = this.down('rallygridboard').getGridOrBoard();
247280
if (grid){
248-
return _.filter(grid.columns, function(item){ return (item.dataIndex && item.dataIndex != "DragAndDropRank"); });
281+
return _.filter(grid.columns, function(item){
282+
return (
283+
item.dataIndex &&
284+
item.dataIndex != "DragAndDropRank" &&
285+
item.xtype &&
286+
item.xtype != "rallytreerankdraghandlecolumn" &&
287+
item.xtype != "rallyrowactioncolumn" &&
288+
item.text != " ");
289+
});
249290
}
250291
return [];
251292
},
@@ -289,6 +330,7 @@ Ext.define("custom-grid-with-deep-export", {
289330
this.logger.log('_export', fetch, args, columns, filters.toString(), childModels, sorters);
290331

291332
var exporter = Ext.create('Rally.technicalservices.HierarchyExporter', {
333+
modelName: modelName,
292334
fileName: 'hierarchy-export.csv',
293335
columns: columns,
294336
portfolioItemTypeObjects: this.portfolioItemTypes

src/javascript/utils/hierarchy-exporter.js

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Ext.define('Rally.technicalservices.HierarchyExporter',{
99

1010
constructor: function (config) {
1111
this.mixins.observable.constructor.call(this, config);
12+
this.modelName = config.modelName;
1213
this.records = [];
1314
this.fileName = config.fileName || "export.csv";
1415
this.columns = config.columns || [{dataIndex: 'FormattedID', text: 'ID'},{dataIndex: 'Name', text: 'Name'}];
@@ -28,7 +29,11 @@ Ext.define('Rally.technicalservices.HierarchyExporter',{
2829
hierarchicalData = this._buildHierarchy(),
2930
exportData = this._getExportableHierarchicalData(hierarchicalData,columns);
3031

31-
columns = this._getAncestorTypeColumns(hierarchicalData[0]._type).concat(columns);
32+
var ancestorType = this.modelName.toLowerCase();
33+
if ( hierarchicalData.length > 0 ) {
34+
ancestorType = hierarchicalData[0]._type;
35+
}
36+
columns = this._getAncestorTypeColumns(ancestorType).concat(columns);
3237

3338
var csv = this._transformDataToDelimitedString(exportData, columns);
3439

@@ -234,29 +239,33 @@ Ext.define('Rally.technicalservices.HierarchyExporter',{
234239
return rec;
235240
},
236241
_getAncestorTypeColumns: function(rootModel){
237-
var piTypes = this.portfolioItemTypeObjects,
238-
piIdx = -1;
239-
240-
Ext.Array.each(piTypes, function(piObj, idx){
241-
if (piObj.typePath.toLowerCase() === rootModel.toLowerCase()){
242-
piIdx = idx;
243-
}
244-
});
245-
246-
var columns = [{
247-
dataIndex: 'hierarchicalrequirement',
248-
text: 'User Story'
249-
}];
250-
251-
if (piIdx >= 0){
252-
columns = columns.concat(Ext.Array.map(piTypes.slice(0,piIdx+1), function(piObj) { return { dataIndex: piObj.typePath.toLowerCase(), text: piObj.name };} ));
242+
var modelName = rootModel.toLowerCase();
243+
var columns = [];
244+
if ( modelName == 'hierarchicalrequirement' || modelName.startsWith('portfolioitem') ) {
245+
var piTypes = this.portfolioItemTypeObjects,
246+
piIdx = -1;
247+
248+
Ext.Array.each(piTypes, function(piObj, idx){
249+
if (piObj.typePath.toLowerCase() === rootModel.toLowerCase()){
250+
piIdx = idx;
251+
}
252+
});
253+
253254
columns.push({
254-
dataIndex: 'type',
255-
text: 'Artifact Type'
255+
dataIndex: 'hierarchicalrequirement',
256+
text: 'User Story'
256257
});
257-
258+
259+
if (piIdx >= 0){
260+
columns = columns.concat(Ext.Array.map(piTypes.slice(0,piIdx+1), function(piObj) { return { dataIndex: piObj.typePath.toLowerCase(), text: piObj.name };} ));
261+
columns.push({
262+
dataIndex: 'type',
263+
text: 'Artifact Type'
264+
});
265+
266+
}
267+
columns.reverse();
258268
}
259-
columns.reverse();
260269
return columns;
261270
},
262271
saveCSVToFile:function(csv,file_name,type_object){

src/javascript/utils/settings.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
model: Ext.identityFn('TypeDefinition'),
5151
sorters: [{ property: 'DisplayName' }],
5252
fetch: ['DisplayName', 'ElementName', 'TypePath', 'Parent', 'UserListable'],
53-
filters: type_filters,
53+
//filters: type_filters,
54+
filters: [{ property: 'UserListable', value: true }],
5455
autoLoad: false,
5556
remoteSort: false,
5657
remoteFilter: true

0 commit comments

Comments
 (0)