forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StoriesByCreatorApp.html
192 lines (167 loc) · 8.31 KB
/
StoriesByCreatorApp.html
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Copyright (c) 2002-2011 Rally Software Development Corp. All rights reserved. -->
<html>
<head>
<title>Stories By Creator</title>
<meta name="Name" content="App: Stories by Creator"/>
<meta name="Version" content="2012.01.14"/>
<meta name="Vendor" content="Rally Software"/>
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.29"></script>
<script type="text/javascript">
function StoriesByCreator(rallyDataSource) {
var releaseHolder, tableHolder;
var releaseDropdown;
var table;
var wait = null;
// private method the builds the table of stories and associated info
function showResults(results) {
if (wait) {
wait.hide();
wait = null;
}
if (results.stories.length === 0) {
tableHolder.innerHTML = "No stories associated with the selected release were found";
return;
}
var config = { 'columnKeys' : ['FormattedID', 'Name', 'ScheduleState',
'CreationDate', 'CreatedBy', 'Owner', 'AcceptedBy' ],
'columnHeaders' : ['Formatted ID', 'Story Name', 'Schedule State',
'Date Created', 'Created By', 'Owner', 'Accepted By'],
'columnWidths' : ['85px', '360px', '100px',
'150px', '120px', '120px', '120px']
};
table = new rally.sdk.ui.Table(config);
var i, j, story;
var linkConfig = null;
var storyLink = null;
var cd = null; // for story.CreationDate formatting
var initialRevisionIx, initialRevision;
var creator = null;
var owner = null;
var acceptor = null;
var creators = {};
var revision = null;
for (i = 0; i < results.stories.length; i++) {
story = results.stories[i];
// somewhat counter-intuitively, the revisions are returned in last to first order
// so the initial revision is the last in the list of revisions
initialRevisionIx = story.RevisionHistory.Revisions.length - 1;
initialRevision = story.RevisionHistory.Revisions[initialRevisionIx];
creator = initialRevision.User._refObjectName;
// fill an object that holds creator names so that we can later show table grouped in
// creator order
if (!(creator in creators)) {
creators[creator] = [];
}
cd = '' + initialRevision.CreationDate;
cd = cd.replace(/T/, " ").replace(/\.\d+Z+/, " UTC");
story.CreationDate = cd;
story.CreatedBy = creator;
//
// cycle through the revisions from last towards the first looking for
// 'changed from [Completed] to [Accepted]' in the revision.Description
// and grab for the author on that revision as the Acceptor value
//
acceptor = '';
var srchIx = null;
if (story.ScheduleState === 'Accepted') {
acceptor = creator; // default to this to handle when initial version was also Accepted
for (j = 0; j < story.RevisionHistory.Revisions.length; j++) {
revision = story.RevisionHistory.Revisions[j];
srchIx = revision.Description.search(/SCHEDULE STATE changed from \[.+\] to \[Accepted\]/);
if (srchIx > 0) {
acceptor = '';
if (revision.User && revision.User._refObjectName) {
acceptor = revision.User._refObjectName;
}
break;
}
}
}
story.AcceptedBy = acceptor;
creators[creator].push(story);
}
var creatorNames = [];
for (var cn in creators) {
if (creators.hasOwnProperty(cn)) {
creatorNames.push(cn);
}
}
creatorNames.sort();
for (i = 0; i < creatorNames.length; i++) {
creator = creatorNames[i];
var stories = creators[creator];
for (j = 0; j < stories.length; j++) {
story = stories[j];
linkConfig = {item: {FormattedID: story.FormattedID, "_ref" : story._ref}};
storyLink = new rally.sdk.ui.basic.Link(linkConfig);
story.FormattedID = storyLink.renderToHtml();
owner = story.Owner === null ? '' : story.Owner._refObjectName;
story.Owner = owner;
table.addRow(story);
}
}
table.display(tableHolder);
}
//private method to query for stories when release selection changes
function runMainQuery(sender, eventArgs) {
if (table) {
table.destroy();
table = null;
}
tableHolder.innerHTML = "";
var release = releaseDropdown.getSelectedName();
if ((release === null) || (release.length === 0)) {
tableHolder.innerHTML = "No release was defined. Please select another workspace/project.";
return;
}
var queryCriteria = '(Release.Name = "' + release + '")';
var queryConfig =
{
key : "stories",
type : "HierarchicalRequirement",
fetch : "FormattedID,Name,Owner,DisplayName,RevisionHistory,Revisions,RevisionNumber,Project,ScheduleState",
order : "FormattedID",
query : queryCriteria
};
wait = new rally.sdk.ui.basic.Wait({});
wait.display('wait');
rallyDataSource.findAll(queryConfig, showResults);
}
//private method to start building controls on page
//page consists of a dropdown to select the release and the table to hold the query results
function initPage() {
releaseHolder = document.getElementById('release');
tableHolder = document.getElementById('table');
var rdConfig = { label : "Select a release: ",
showLabel: true,
labelPosition: "before"
};
releaseDropdown = new rally.sdk.ui.ReleaseDropdown(rdConfig, rallyDataSource);
releaseDropdown.display(releaseHolder, runMainQuery);
}
// only public method
this.display = function() {
rally.sdk.ui.AppHeader.setHelpTopic("250");
rally.sdk.ui.AppHeader.showPageTools(true);
initPage();
};
}
</script>
<script type="text/javascript">
rally.addOnLoad(function() {
var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
var storiesByCreator = new StoriesByCreator(rallyDataSource);
storiesByCreator.display();
});
</script>
</head>
<body>
<div id="release" style="float:left"></div>
<div id="wait" style="float:left; height: 16px; width: 24px;"></div>
<div id="table" style="clear:both;padding-top:15px"></div>
</body>
</html>