-
Notifications
You must be signed in to change notification settings - Fork 217
/
TraceabilityMatrixApp.html
331 lines (277 loc) · 13.2 KB
/
TraceabilityMatrixApp.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Copyright (c) 2011 Rally Software Development Corp. All rights reserved -->
<html>
<head>
<title>Traceability Matrix</title>
<meta name="Name" content="App: Traceability Matrix"/>
<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 TraceabilityMatrix() {
var dataSource, chooser, chooseButton, epicTable, childTable;
this.display = function() {
dataSource = new rally.sdk.data.RallyDataSource(
'__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
rally.sdk.ui.AppHeader.showPageTools(true);
rally.sdk.ui.AppHeader.addPageTool(rally.sdk.ui.PageTools.BuiltIn.Print);
rally.sdk.ui.AppHeader.setHelpTopic("257");
dataSource.find({
key:"prd",
type:"HierarchicalRequirement",
query: "( Tags.Name = PRD )",
fetch:"Name"
}, dojo.hitch(this, this._showChooserOrInstructions));
};
this._showChooserOrInstructions = function(results) {
if (results.prd.length > 0) {
dojo.byId("signAndDate").innerHTML =
'Signature _________________________<br/>' +
'Date Printed ' + dojo.date.locale.format(new Date(), 'MM/DD/yyyy');
if (!chooseButton) {
chooseButton = new rally.sdk.ui.basic.Button({text:'Choose a Product Requirement'});
chooseButton.display('chooseButton', function() {
chooser.display();
});
}
var chooserConfig = {
fetch:"FormattedID,Name,Description",
query:'Tags.Name = PRD',
title: 'Product Requirement Chooser'
};
chooser = new rally.sdk.ui.Chooser(chooserConfig, dataSource);
chooser.addEventListener('onClose', dojo.hitch(this, this._displayChosenPRD));
chooser.display();
} else {
var instructionsDiv = document.createElement("div");
dojo.addClass(instructionsDiv, "instructions");
var instructions = document.createElement("span");
dojo.addClass(instructions, "quote");
instructions.innerHTML = "<p><b>No PRDs Found.</b></p><p>This app keys off of special tags. To get started, you'll need to let Rally know which user stories represent your Product Requirements Documents by tagging them 'PRD'.</p><p >The Traceability Matrix App allows you to show traceability from product requirements to the test cases that prove their implementation and the corresponding results.</p>";
instructionsDiv.appendChild(instructions);
var learnMoreLinkElement = document.createElement("a");
dojo.attr(learnMoreLinkElement, "href", "http://www.rallydev.com/help/traceability-matrix-0");
dojo.attr(learnMoreLinkElement, "target", "new");
learnMoreLinkElement.innerHTML = "Learn more about how to use the Traceability Matrix";
instructions.appendChild(learnMoreLinkElement);
var exampleImage = document.createElement("img");
dojo.attr(exampleImage, "src", "/apps/resources/TraceabilityMatrix/example.png");
dojo.addClass(exampleImage, "exampleImage");
instructionsDiv.appendChild(exampleImage);
dojo.byId("display").appendChild(instructionsDiv);
}
};
this._displayChosenPRD = function(chooser, args) {
dataSource.findAll({
key:"epicStories",
type:"HierarchicalRequirement",
query: "( ObjectID = " + rally.sdk.util.Ref.getOidFromRef(args.selectedItem._ref) + ")",
order:"Name",
fetch:"Children,Name,TestCases,LastVerdict,Source,Risk,Attachments,LastRun,FormattedID,,Results,Tester,Owner,Type"
}, dojo.hitch(this, this.showTables));
};
this.displayEpicTable = function(epic) {
var tableConfig = {
'columnKeys' : ["FormattedId",'TestCaseFormattedId','TestCaseName',"Type",'Source', 'Risk','OwnerName','LastRun','LastVerdict','Attachment'],
'columnHeaders': ["User Story",'Test Case ID','Test Case Name',"Type",'Source', 'Risk','Owner','Last Run','Last Verdict','Design Output'],
sortingEnabled:false
};
var nameContainer = dojo.byId("prdName");
nameContainer.innerHTML = this.objectToLinkMarkup(epic.FormattedID, epic);
nameContainer.appendChild(document.createTextNode(" - " + epic.Name));
epicTable = new rally.sdk.ui.Table(tableConfig);
epicTable.addRows(this.createTableRowObject(epic, epic.Source));
epicTable.display("parentTable");
};
this.displayChildTable = function(epic) {
var tableConfig = {
'columnKeys' : ["FormattedId",'TestCaseFormattedId','TestCaseName',"Type",'Source', 'Risk','OwnerName','LastRun','LastVerdict','Attachment'],
'columnHeaders': ["User Story",'Test Case ID','Test Case Name',"Type",'Source', 'Risk','Owner','Last Run','Last Verdict','Design Output'],
sortingEnabled:false
};
var rows = [];
dojo.forEach(epic.Children, function(child) {
rows = rows.concat(this.createTableRowObject(child, epic.Source));
}, this);
childTable = new rally.sdk.ui.Table(tableConfig);
childTable.addRows(rows);
childTable.display("childTable");
};
this.objectToLinkMarkup = function(text, object) {
return new rally.sdk.ui.basic.Link({
text: text,
item:object
}).renderToHtml();
};
this.createAttachmentLink = function(attachment) {
var href = "https://" + dataSource.getServer() + "/slm/attachment/" + rally.sdk.util.Ref.getOidFromRef(attachment) + "/" + attachment.Name;
var linkElement = document.createElement("a");
dojo.attr(linkElement, "href", href);
linkElement.appendChild(document.createTextNode(attachment.Name));
var container = document.createElement("div");
container.appendChild(linkElement);
var html = container.innerHTML;
dojo.destroy(container);
return html;
};
this.formatDate = function(dateString) {
var dateObject = rally.sdk.util.DateTime.fromIsoString(dateString);
return rally.sdk.util.DateTime.format(dateObject, "MM/dd/yyy");
};
this.createStoryRowObject = function(story, source) {
var tempObject;
tempObject = {};
tempObject.FormattedId = this.objectToLinkMarkup(story.FormattedID, story) + "<span>-" + story.Name + "</span>";
tempObject.Source = source;
tempObject.Name = story.Name;
return tempObject;
};
this.createTestCaseObject = function(story, source, testCase, attachment) {
var tempObject = this.createStoryRowObject(story, source);
if (attachment) {
tempObject.Attachment = this.createAttachmentLink(attachment);
}
if (testCase) {
tempObject.TestCase = testCase;
tempObject.Type = testCase.Type;
tempObject.OwnerName = testCase.Owner._refObjectName;
tempObject.TestCaseFormattedId = this.objectToLinkMarkup(testCase.FormattedID, testCase);
tempObject.TestCaseName = testCase.Name;
tempObject.LastVerdict = testCase.LastVerdict || "...";
tempObject.LastRun = testCase.LastRun ? this.formatDate(testCase.LastRun) : "...";
tempObject.Risk = testCase.Risk;
}
return tempObject;
};
this.createTableRowObject = function(input, source) {
try {
var results = [];
var story = dojo.clone(input);
while (story.Attachments.length + story.TestCases.length) {
var currentAttachment = story.Attachments.length ? story.Attachments.pop() : false;
var currentTestCase = story.TestCases.length ? story.TestCases.pop() : false;
results.push(this.createTestCaseObject(story, source, currentTestCase, currentAttachment));
}
if (results.length) {
results.sort(function(a, b) {
if (a.FormattedId === b.FormattedId) {
return a.TestCaseFormattedId > b.TestCaseFormattedId;
}
return a.FormattedId > b.FormattedId;
});
return results;
}
else {
return [this.createStoryRowObject(story, source)];
}
}
catch(ex) {
console.log(ex.stack);
throw ex;
}
};
this.showTables = function(results) {
if (epicTable) {
epicTable.destroy();
}
if (childTable) {
childTable.destroy();
}
if (!results.epicStories || !results.epicStories.length) {
console.log("No epic stories found for objectId");
return;
}
var story = results.epicStories.pop();
dojo.byId("parentTableContainer").style.display = "block";
dojo.byId("childTableContainer").style.display = "block";
this.displayEpicTable(story);
this.displayChildTable(story);
};
}
</script>
<style type="text/css">
.tableContainer {
display: none;
text-align: center;
}
.onlyPrint {
display: none;
}
#signAndDate {
font-size: 12px;
line-height: 18px;
margin-top: 50px;
}
.instructions {
max-width: 1000px;
font-size: 14px;
color: #333333;
}
.instructions .quote {
font-size: 14px;
color: #333333;
float: left;
}
.instructions p {
width: 400px;
font-size: 12px;
}
.instructionsTitle {
font-weight: bold;
}
.exampleImage {
float: left;
margin: 10px;
/* for IE */
filter: alpha(opacity = 70);
/* CSS3 standard */
opacity: 0.7;
}
@media print {
.noPrint {
display: none;
}
#date {
margin-bottom: 50px;
}
@page {
height: 7.5in;
width: 10in;
margin: .5in;
size: landscape;
}
.onlyPrint {
display: block;
}
#appHeaderright {
display: none;
}
}
</style>
<script type="text/javascript">
function onLoad() {
var traceabilityMatrix = new TraceabilityMatrix();
traceabilityMatrix.display();
}
rally.addOnLoad(onLoad);
</script>
</head>
<body>
<div id="chooseButton" class="noPrint"></div>
<div id="display">
<div id="parentTableContainer" class="tableContainer">
<h3><span id="prdName"></span></h3>
<div id="parentTable"></div>
</div>
<br/>
<div id="childTableContainer" class="tableContainer">
<h3>SRS Traceability Table</h3>
<div id="childTable"></div>
</div>
</div>
<div id="signAndDate" class="onlyPrint"></div>
</body>
</html>