Skip to content

Commit df1a3b2

Browse files
authored
Merge pull request #33 from RallyTechServices/piFilter
Pi filter
2 parents 46f3f68 + 797a289 commit df1a3b2

File tree

7 files changed

+97
-93
lines changed

7 files changed

+97
-93
lines changed

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"apiKey": "_PUT_APIKEY_HERE_",
66
"javascript": [
77
"node_modules/@agile-central-technical-services/utils-shared-views/index.js",
8+
"node_modules/@agile-central-technical-services/utils-ancestor-pi-inline-filter/index.js",
89
"src/javascript/utils/*.js",
910
"src/javascript/*.js"
1011
]

deploy/Ugly.txt

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

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "custom-grid-with-deep-export",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"scripts": {
55
"debug": "grunt debug",
66
"debug:watch": "nodemon --exec grunt debug",
@@ -10,22 +10,26 @@
1010
},
1111
"dependencies": {},
1212
"devDependencies": {
13+
"@agile-central-technical-services/utils-ancestor-pi-inline-filter": "^1.0.3",
14+
"@agile-central-technical-services/utils-shared-views": "^1.0.0",
1315
"grunt": "~0.4.5",
1416
"grunt-cli": "0.1.6",
1517
"grunt-contrib-jasmine": "1.1.0",
16-
"grunt-templater": "git://github.com/rockwood/grunt-templater.git",
17-
"underscore": "1.8.3",
18-
"grunt-prompt": "^1.3.3",
1918
"grunt-contrib-uglify": "0.3.2",
20-
"request": "2.67",
2119
"grunt-contrib-watch": "1.0.0",
22-
"username": "2.1.0",
20+
"grunt-prompt": "^1.3.3",
21+
"grunt-templater": "git://github.com/rockwood/grunt-templater.git",
22+
"nodemon": "^1.14.11",
2323
"rally-sdk2-test-utils": "0.1.2",
24-
"nodemon": "^1.14.11"
24+
"request": "2.67",
25+
"underscore": "1.8.3",
26+
"username": "2.1.0"
2527
},
2628
"nodemonConfig": {
2729
"watch": [
28-
"src/*", "templates/*", "*.json"
30+
"src/*",
31+
"templates/*",
32+
"*.json"
2933
],
3034
"verbose": true
3135
}

src/javascript/app.js

Lines changed: 58 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ Ext.define("custom-grid-with-deep-export", {
33
componentCls: 'app',
44
logger: new Rally.technicalservices.Logger(),
55
layout: {
6-
type: 'vbox',
6+
type:'vbox',
77
align: 'stretch'
88
},
9-
9+
items: [{
10+
id: 'grid-area',
11+
xtype: 'container',
12+
flex: 1,
13+
type: 'vbox',
14+
align: 'stretch'
15+
}],
1016
config: {
1117
defaultSettings: {
1218
columnNames: ['FormattedID', 'Name','ScheduleState'] ,
@@ -28,25 +34,39 @@ Ext.define("custom-grid-with-deep-export", {
2834
statePrefix: 'customlist',
2935
allowExpansionStateToBeSaved: false,
3036
enableAddNew: true,
31-
3237
onTimeboxScopeChange: function(newTimeboxScope) {
3338
this.callParent(arguments);
3439
this._buildStore();
3540
},
36-
3741
launch: function () {
38-
this.fetchPortfolioItemTypes().then({
42+
Rally.data.util.PortfolioItemHelper.getPortfolioItemTypes()
43+
.then({
3944
success: function(portfolioItemTypes){
40-
this.portfolioItemTypes = portfolioItemTypes;
45+
this.portfolioItemTypes = _.sortBy(portfolioItemTypes, function(type) {
46+
return type.get('Ordinal');
47+
});
4148
this._buildStore();
4249
},
4350
failure: function(msg){
4451
this._showError(msg);
4552
},
4653
scope: this
4754
});
48-
55+
var listenerConfig = {
56+
scope: this
57+
}
4958
},
59+
60+
// Usual monkey business to size gridboards
61+
onResize: function() {
62+
this.callParent(arguments);
63+
var gridArea = this.down('#grid-area');
64+
var gridboard = this.down('rallygridboard');
65+
if ( gridArea && gridboard) {
66+
gridboard.setHeight(gridArea.getHeight())
67+
}
68+
},
69+
5070
_buildStore: function(){
5171

5272
this.modelNames = [this.getSetting('type')];
@@ -69,8 +89,8 @@ Ext.define("custom-grid-with-deep-export", {
6989
});
7090
},
7191
_addGridboard: function(store) {
72-
73-
this.removeAll();
92+
var gridArea = this.down('#grid-area')
93+
gridArea.removeAll();
7494

7595
var filters = this.getSetting('query') ? [Rally.data.wsapi.Filter.fromQueryString(this.getSetting('query'))] : [];
7696
var timeboxScope = this.getContext().getTimeboxScope();
@@ -85,31 +105,32 @@ Ext.define("custom-grid-with-deep-export", {
85105
dataContext.project = null;
86106
}
87107
var summaryRowFeature = Ext.create('Rally.ui.grid.feature.SummaryRow');
88-
this.gridboard = this.add({
108+
var currentModelName = this.modelNames[0];
109+
this.gridboard = gridArea.add({
89110
xtype: 'rallygridboard',
90-
flex: 1,
91111
context: context,
92112
modelNames: this.modelNames,
93113
toggleState: 'grid',
114+
height: gridArea.getHeight(),
115+
listeners: {
116+
scope: this,
117+
viewchange: this.viewChange,
118+
},
94119
plugins: [
95120
'rallygridboardaddnew',
96121
{
97122
ptype: 'rallygridboardinlinefiltercontrol',
98123
inlineFilterButtonConfig: {
99124
stateful: true,
100-
stateId: this.getContext().getScopedStateId('filters-1'),
125+
stateId: this.getModelScopedStateId(currentModelName, 'filters'),
101126
modelNames: this.modelNames,
102127
inlineFilterPanelConfig: {
103128
quickFilterPanelConfig: {
129+
portfolioItemTypes: this.portfolioItemTypes,
130+
modelName: currentModelName,
104131
whiteListFields: [
105132
'Tags',
106133
'Milestones'
107-
],
108-
defaultFields: [
109-
'ArtifactSearch',
110-
'Owner',
111-
'ModelType',
112-
'Milestones'
113134
]
114135
}
115136
}
@@ -120,7 +141,7 @@ Ext.define("custom-grid-with-deep-export", {
120141
headerPosition: 'left',
121142
modelNames: this.modelNames,
122143
stateful: true,
123-
stateId: this.getContext().getScopedStateId('field-picker')
144+
stateId: this.getModelScopedStateId(currentModelName, 'fields')
124145
},
125146
{
126147
ptype: 'rallygridboardactionsmenu',
@@ -131,8 +152,12 @@ Ext.define("custom-grid-with-deep-export", {
131152
},
132153
{
133154
ptype: 'rallygridboardsharedviewcontrol',
134-
stateful: true,
135-
stateId: this.getContext().getScopedStateId('shared-views')
155+
sharedViewConfig: {
156+
enableUrlSharing: this.isFullPageApp !== false,
157+
stateful: true,
158+
stateId: this.getModelScopedStateId(currentModelName, 'views'),
159+
stateEvents: ['select','beforedestroy']
160+
},
136161
}
137162
],
138163
cardBoardConfig: {
@@ -167,6 +192,15 @@ Ext.define("custom-grid-with-deep-export", {
167192
}
168193
});
169194
},
195+
196+
viewChange: function() {
197+
this._buildStore();
198+
},
199+
200+
getModelScopedStateId: function(modelName, id) {
201+
return this.getContext().getScopedStateId(modelName + '-' + id);
202+
},
203+
170204
_getExportMenuItems: function(){
171205
var result = [];
172206
this.logger.log('_getExportMenuItems', this.modelNames[0]);
@@ -256,7 +290,9 @@ Ext.define("custom-grid-with-deep-export", {
256290
return result;
257291
},
258292
getPortfolioItemTypeNames: function(){
259-
return _.pluck(this.portfolioItemTypes, 'typePath');
293+
return _.map(this.portfolioItemTypes, function(type) {
294+
return type.get('TypePath');
295+
});
260296
},
261297

262298
_showError: function(msg){
@@ -413,57 +449,5 @@ Ext.define("custom-grid-with-deep-export", {
413449
return Rally.technicalservices.CustomGridWithDeepExportSettings.getFields({
414450
showSearchAllProjects: this.isMilestoneScoped()
415451
});
416-
},
417-
//onSettingsUpdate: Override
418-
onSettingsUpdate: function (settings){
419-
this.logger.log('onSettingsUpdate',settings);
420-
// Ext.apply(this, settings);
421-
this._buildStore();
422-
},
423-
fetchPortfolioItemTypes: function(){
424-
var deferred = Ext.create('Deft.Deferred');
425-
426-
var store = Ext.create('Rally.data.wsapi.Store', {
427-
model: 'TypeDefinition',
428-
fetch: ['TypePath', 'Ordinal','Name'],
429-
filters: [
430-
{
431-
property: 'Parent.Name',
432-
operator: '=',
433-
value: 'Portfolio Item'
434-
},
435-
{
436-
property: 'Creatable',
437-
operator: '=',
438-
value: 'true'
439-
}
440-
],
441-
sorters: [{
442-
property: 'Ordinal',
443-
direction: 'ASC'
444-
}]
445-
});
446-
store.load({
447-
callback: function(records, operation, success){
448-
449-
if (success){
450-
var portfolioItemTypes = new Array(records.length);
451-
_.each(records, function(d){
452-
//Use ordinal to make sure the lowest level portfolio item type is the first in the array.
453-
var idx = Number(d.get('Ordinal'));
454-
portfolioItemTypes[idx] = { typePath: d.get('TypePath').toLowerCase(), name: d.get('Name') };
455-
//portfolioItemTypes.reverse();
456-
});
457-
deferred.resolve(portfolioItemTypes);
458-
} else {
459-
var error_msg = '';
460-
if (operation && operation.error && operation.error.errors){
461-
error_msg = operation.error.errors.join(',');
462-
}
463-
deferred.reject('Error loading Portfolio Item Types: ' + error_msg);
464-
}
465-
}
466-
});
467-
return deferred.promise;
468452
}
469453
});

src/javascript/utils/hierarchy-exporter.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ Ext.define('Rally.technicalservices.HierarchyExporter',{
195195

196196
var displayName = '';
197197
Ext.Array.each(this.portfolioItemTypeObjects, function(p){
198-
if (p.typePath.toLowerCase() === modelName.toLowerCase()){
199-
displayName = p.name;
198+
if (p.get('TypePath').toLowerCase() === modelName.toLowerCase()){
199+
displayName = p.get('Name');
200200
return false;
201201
}
202202
});
@@ -246,7 +246,7 @@ Ext.define('Rally.technicalservices.HierarchyExporter',{
246246
piIdx = -1;
247247

248248
Ext.Array.each(piTypes, function(piObj, idx){
249-
if (piObj.typePath.toLowerCase() === rootModel.toLowerCase()){
249+
if (piObj.get('TypePath').toLowerCase() === rootModel.toLowerCase()){
250250
piIdx = idx;
251251
}
252252
});
@@ -257,7 +257,12 @@ Ext.define('Rally.technicalservices.HierarchyExporter',{
257257
});
258258

259259
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 };} ));
260+
columns = columns.concat(Ext.Array.map(piTypes.slice(0,piIdx+1), function(piObj) {
261+
return {
262+
dataIndex: piObj.get('TypePath').toLowerCase(),
263+
text: piObj.get('Name')
264+
};
265+
} ));
261266
columns.push({
262267
dataIndex: 'type',
263268
text: 'Artifact Type'

src/javascript/utils/hierarchy-loader.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Ext.define('Rally.technicalservices.HierarchyLoader',{
7171

7272
this.fireEvent('hierarchyloadartifactsloaded', type, args);
7373

74-
var portfolioItemTypePaths = _.pluck(this.portfolioItemTypes, 'typePath'),
74+
var portfolioItemTypePaths = _.map(this.portfolioItemTypes, function(type) {
75+
return type.get('TypePath');
76+
}),
7577
portfolioItemOrdinal = _.indexOf(portfolioItemTypePaths, type);
7678

7779
if (portfolioItemOrdinal === 0 && Ext.Array.contains(this.loadChildModels, this.storyModelName)) {
@@ -143,7 +145,7 @@ Ext.define('Rally.technicalservices.HierarchyLoader',{
143145
var type = this.storyModelName,
144146
fetch = this.fetch.concat(this.getRequiredFetchFields(type)),
145147
chunks = this._getChunks(parentRecords, 'LeafStoryCount'),
146-
featureParentName = this.portfolioItemTypes[0].name.replace(/\s/g, '') + ".ObjectID";
148+
featureParentName = this.portfolioItemTypes[0].get('Name').replace(/\s/g, '') + ".ObjectID";
147149

148150
return this.fetchChunks(type, fetch, chunks, featureParentName, Ext.String.format("Please Wait... Loading User Stories for {0} Portfolio Items", parentRecords.length));
149151
},

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
# yarn lockfile v1
33

44

5+
"@agile-central-technical-services/utils-ancestor-pi-inline-filter@^1.0.3":
6+
version "1.0.3"
7+
resolved "https://registry.yarnpkg.com/@agile-central-technical-services/utils-ancestor-pi-inline-filter/-/utils-ancestor-pi-inline-filter-1.0.3.tgz#12d07db1acdd894ecec3e2f168e7ba72b88924f8"
8+
9+
"@agile-central-technical-services/utils-shared-views@^1.0.0":
10+
version "1.0.0"
11+
resolved "https://registry.yarnpkg.com/@agile-central-technical-services/utils-shared-views/-/utils-shared-views-1.0.0.tgz#de98f885ab2f1e44129c34b6c020431333de271e"
12+
513
"@sinonjs/commons@^1.0.2":
614
version "1.0.2"
715
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.0.2.tgz#3e0ac737781627b8844257fadc3d803997d0526e"

0 commit comments

Comments
 (0)