forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PortfolioHierarchyApp.js
158 lines (135 loc) · 5.41 KB
/
PortfolioHierarchyApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
(function() {
var Ext = window.Ext4 || window.Ext;
/**
* Portfolio Hierarchy App
* View and rearrange PIs and their user stories
*/
Ext.define('Rally.apps.portfoliohierarchy.PortfolioHierarchyApp', {
extend: 'Rally.app.App',
requires: [
'Rally.data.util.PortfolioItemHelper',
'Rally.ui.notify.Notifier',
'Rally.data.wsapi.Filter',
'Rally.util.Help',
'Rally.util.Test'
],
layout: 'auto',
items:[
{
xtype:'container',
itemId:'header',
cls:'header'
},
{
xtype:'container',
itemId:'bodyContainer'
}
],
appName: 'Portfolio Hierarchy',
cls: 'portfolio-hierarchy-app',
launch: function() {
if(Rally.environment.getContext().getSubscription().isModuleEnabled('Rally Portfolio Manager')) {
Rally.data.util.PortfolioItemHelper.loadTypeOrDefault({
typeRef: this.getSetting('type'),
context: this.getContext().getDataContext(),
defaultToLowest: false,
success: this.addTreeForType,
scope: this
});
} else {
this.down('#bodyContainer').add({
xtype: 'container',
html: '<div class="rpm-turned-off" style="padding: 50px; text-align: center;">You do not have RPM enabled for your subscription</div>'
});
if (Rally.BrowserTest) {
Rally.BrowserTest.publishComponentReady(this);
}
}
this.tooltip = Ext.create('Rally.ui.tooltip.StateToolTip', {
target: this.getEl(),
listeners: {
beforeshow: function(tooltip) {
var triggerEl = Ext.get(tooltip.triggerElement);
var stateValue = triggerEl.getAttribute('state-data');
if (stateValue) {
tooltip.update(stateValue);
}
},
scope: this
}
});
},
onDestroy: function() {
this.tooltip.destroy();
this.callParent(arguments);
},
_drawHeader: function(){
var header = this.down('#header');
header.add(this._buildHelpComponent());
header.add(this._buildFilterInfo());
},
addTreeForType: function(record){
this.typePath = record.get('Name');
this._drawHeader();
var tree = this.buildTreeForType(record);
this.down('#bodyContainer').add(tree);
tree.on('initialload', function(){
if (Rally.BrowserTest) {
Rally.BrowserTest.publishComponentReady(this);
}
}, this);
},
buildTreeForType: function(typeRecord){
var me = this;
var filters = [];
if (this.getSetting('query')) {
try {
filters.push(Rally.data.QueryFilter.fromQueryString(this.getSetting('query')));
} catch (e) {
Rally.ui.notify.Notifier.showError({
message: e.message
});
}
}
return Ext.create('Rally.ui.tree.PortfolioTree', {
stateful: true,
stateId: this.getAppId() + 'rallyportfoliotree',
workspace: this.getContext().getWorkspace(),
shouldRetrievePlanData: !!Rally.environment.getContext().isFeatureEnabled("ROADMAP_PLANNING_PAGE"),
topLevelModel: typeRecord.get('TypePath'),
topLevelStoreConfig: {
filters: filters,
context: this.getContext().getDataContext()
},
childItemsStoreConfigForParentRecordFn: function(){
return {
context: {
project: undefined,
workspace: me.getContext().getDataContext().workspace
},
fetch: this._getChildLevelFetchFields()
};
},
emptyText: '<p>No portfolio items of this type found.</p>' +
'<p>Click the gear to set your project to match the location of your portfolio items or to filter further by type.</p>'
});
},
_buildHelpComponent:function () {
return Ext.create('Ext.Component', {
cls:Rally.util.Test.toBrowserTestCssClass('portfolio-hierarchy-help-container'),
renderTpl: Rally.util.Help.getIcon({
id: 268
})
});
},
_buildFilterInfo: function(){
return Ext.create('Rally.ui.tooltip.FilterInfo', {
projectName: this.getSetting('project') && this.getContext().get('project').Name || 'Following Global Project Setting',
typePath: this.typePath,
scopeUp: this.getSetting('projectScopeUp'),
scopeDown: this.getSetting('projectScopeDown'),
query: this.getSetting('query')
});
}
});
})();