forked from paulmunro/Rally
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRally - Defect and Story Print Cards.html
508 lines (440 loc) · 16.5 KB
/
Rally - Defect and Story Print Cards.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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!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>Print Story and Defect Cards</title>
<meta name="Name" content="App: Print Story Cards"/>
<meta name="Version" content="2013.07.24"/>
<meta name="Vendor" content="Paul Munro"/>
<!--<script type="text/javascript" src="/apps/1.29/sdk.js"></script>-->
<script type="text/javascript" src="https://rally1.rallydev.com/apps/1.29/sdk.js?debug=true"></script>
<script type="text/javascript">
var MAX_NAME_LEN = 115;
var APP_TYPE = "";
var CARD_TYPE = "";
var CARDTYPES = [];
CARDTYPES[0] = "HierarchicalRequirement";
CARDTYPES[1] = "defect";
CARDTYPES[2] = "testset";
function PrintTaskCards(rallyDataSource) {
var iterationDropdown, storyDropdown, cbIncludeDefects;
function SetCardTypes(checkbox) {
//Add remove defects from the card list.
var index = CARDTYPES.indexOf("defect");
if (cbIncludeDefects.getChecked() && index === -1) {
CARDTYPES.push("defect");
}
else if (!cbIncludeDefects.getChecked() && index > -1) {
CARDTYPES.splice(index, 1);
}
/*index = CARDTYPES.indexOf("testset");
if (testsetCheckbox.getChecked() && index == -1) {
CARDTYPES.push("testset");
}
else if (!testsetCheckbox.getChecked() && index > -1) {
CARDTYPES.splice(index, 1);
}*/
//If viewing iteration items run query with 'I' filter.
if (iterationDropdown.getDisplayedValue() !== "") {
runQuery("I");
} else {
runQuery("S");
}
}
function displayCards(results) {
var estimate, loginName, ownerClass, storyId, taskId, description,
i, name, theMarkup, data, userTable, ownerText, iCardCount, release;
userTable = buildUserTable(results.users);
for(iCardCount=0; iCardCount<CARDTYPES.length; iCardCount++)
{
CARD_TYPE = CARDTYPES[iCardCount];
data = results[CARD_TYPE];
if (data.length === 0 && iCardCount === CARDTYPES.length) {
dojo.byId("cards").innerHTML = "No Results";
return;
}
for (i = 0; i < data.length; i++) {
name = data[i].Name;
if (name.length > MAX_NAME_LEN) {
name = name.substring(0, MAX_NAME_LEN);
name += "...";
}
loginName = data[i].Owner;
if (typeof loginName === 'undefined' || loginName === null) {
ownerClass = "NoOwner";
ownerText = "No Owner";
} else {
ownerClass = loginName.UserName.replace(/[@|\.]/g, "");
ownerText = makeOwnerText(loginName, userTable);
}
if (CARD_TYPE === 'HierarchicalRequirement' || CARD_TYPE === "defect" || CARD_TYPE === "testset") {
storyId = data[i].FormattedID;
taskId = "";
} else {
storyId = data[i].WorkProduct.FormattedID;
taskId = results.tasks[i].FormattedID;
}
if (data[i].PlanEstimate) {
estimate = data[i].PlanEstimate;
} else if (data[i].Estimate) {
estimate = data[i].Estimate;
} else {
estimate = "0";
}
description = data[i].Description;
if(data[i].Release){
release = data[i].Release.Name;
}
else {
release = "Not Specified";
}
theMarkup = createMarkup(i, data.length, name, ownerText, ownerClass, description,
storyId, taskId, estimate, release);
dojo.byId("cards").innerHTML += theMarkup;
}
}
ownerPopulate(results);
}
function buildUserTable(userData) {
var table = {};
for (var i = 0; i < userData.length; i++) {
table[userData[i].LoginName] = userData[i].DisplayName;
}
return table;
}
function makeOwnerText(loginName, userTable) {
if (typeof userTable[loginName] === 'undefined' || userTable[loginName] === '') {
return loginName._refObjectName.split('@');
} else {
return userTable[loginName];
}
}
function createMarkup(cardNum, totalCards, name, ownerText, ownerClass, description, storyId, taskId, estimate, release) {
var theMarkup, id;
if (CARD_TYPE === 'HierarchicalRequirement' || CARD_TYPE === "defect" || CARD_TYPE === "testset") {
id = storyId;
} else {
id = taskId + ':' + storyId;
}
theMarkup =
'<div class="artifact">' +
'<div class="header" id="' + CARD_TYPE + '">' +
'<span class="storyID">' + id + '</span>' +
'<span class="owner ' + ownerClass + '">' + '</span>' +
'<span class="ownerText">' + ownerText + '</span>' +
'</div>' +
'<div class="content">' +
'<div class="card-title">' + name + '</div>' +
'<div class="description">' + description + '</div>' +
'</div>' +
'<div class="footer">' +
'<span class="release">' + release + '</span>' +
'<span class="estimate">' + estimate + ' Points</span>' +
'</div>' +
'</div>';
// Page break every %x cards
if ((cardNum + 1) % 4 === 0) {
theMarkup = theMarkup + '<div class=pb></div>';
} else if (cardNum === totalCards - 1) {
theMarkup = theMarkup + '<div class=cb> </div>';
}
return theMarkup;
}
function ownerPopulate(results) {
function showOwnerImage(ownerNode) {
ownerNode.innerHTML = "<IMG SRC='" + ownerImage + "'/>";
}
for (i = 0; i < results.users.length; i++) {
var ownerName = results.users[i].UserName.replace(/[@|\.]/g, "");
var ownerImage = rally.sdk.util.Ref.getUserImage(results.users[i], 40);
dojo.forEach(dojo.query("." + ownerName), showOwnerImage);
}
}
function onDataRetrieved(a, eventArgs) {
//Add an "All" option
var all = {};
all[eventArgs.displayValueProperty] = "";
all[eventArgs.valueProperty] = "";
eventArgs.items.unshift(all);
}
function OnIterationChanged(dropdown, eventArgs) {
if (iterationDropdown.getDisplayedValue() != "") {
//Blank out the story field.
storyDropdown.setDisplayedValue("");
dojo.style(dojo.byId('showDefectsCB'), "display", "inline");
}
else {
return;
}
runQuery("I");
}
function OnStoryChanged(dropdown, eventArgs) {
if (storyDropdown.getDisplayedValue() != "") {
//Blank out the iteration field
iterationDropdown.setDisplayedValue("");
dojo.style(dojo.byId('showDefectsCB'), "display", "none");
}
else {
return;
}
runQuery("S");
}
function runQuery(queryType) {
dojo.empty(dojo.byId("cards"));
var queryArray = [];
queryArray[0] = {
key: 'users',
type: 'users',
fetch: 'UserName,ObjectID,DisplayName'
};
var query = "";
switch (queryType) {
case "I":
query = '(Iteration.Name contains "' + iterationDropdown.getSelectedName() + '")';
break;
case "S":
query = '(FormattedID = "' + storyDropdown.getDisplayedValue() + '")';
break;
default:
break;
}
var i = 0;
for (i = 0; i < CARDTYPES.length; i++)
{
queryArray[i+1] = {
key: CARDTYPES[i],
type: CARDTYPES[i],
query: query,
fetch: 'Name,Iteration,WorkProduct,Owner,FormattedID,PlanEstimate,Estimate,ObjectID,Description,UserName,Discipline,Release',
order: 'Rank'
};
}
// fetch the results and call the display function.
rallyDataSource.findAll(queryArray, displayCards);
}
function getStyleSheet() {
var styleSheet;
dojo.forEach(dojo.query('style'), function(s) {
if (s.title == 'printCards') {
styleSheet = s;
}
});
return styleSheet.innerHTML;
}
function printPop() {
var title, options, printWindow, doc, fileref, cardMarkup;
title = CARD_TYPE.slice(0, 1).toUpperCase() + CARD_TYPE.slice(1);
options = "toolbar=1,menubar=1,scrollbars=yes,scrolling=yes,resizable=yes,width=1000,height=500";
printWindow = window.open('', title, options);
doc = printWindow.document;
cardMarkup = dojo.byId("printSection").innerHTML;
doc.write('<html><head><title>' + iterationDropdown.getSelectedName() + ' ' + title + '</title>');
doc.write('<style>');
doc.write(getStyleSheet());
doc.write('</style>');
doc.write('</head><body class="landscape">');
doc.write(cardMarkup);
doc.write('</body></html>');
doc.close();
printWindow.print();
return false;
}
this.display = function () {
var itertationConf = {
label: "Iteration",
showLabel: true,
labelPosition: "after"
};
iterationDropdown = new rally.sdk.ui.IterationDropdown(itertationConf, rallyDataSource);
iterationDropdown.addEventListener("onDataRetrieved", onDataRetrieved);
iterationDropdown.display("iterationDropdown", OnIterationChanged);
var storyConfig = {
type: "hierarchicalrequirement",
attribute: "FormattedID",
label: "Story",
labelPosition: "after",
rememberSelection: "false",
};
storyDropdown = new rally.sdk.ui.ObjectDropdown(storyConfig, rallyDataSource);
storyDropdown.addEventListener("onDataRetrieved", onDataRetrieved);
storyDropdown.display("storyDropdown", OnStoryChanged);
var defectConfig = {
label : "Show Defects",
value : "includeDefects",
showLabel: true,
labelPosition: "after"
};
cbIncludeDefects = new rally.sdk.ui.basic.CheckBox(defectConfig);
cbIncludeDefects.display("showDefectsCB", SetCardTypes);
cbIncludeDefects.setChecked(true);
var config = {
text: "Print " + APP_TYPE + " Cards",
value: "myValue"
};
var button = new rally.sdk.ui.basic.Button(config);
button.display("buttonDiv", printPop);
};
}
</script>
<style type="text/css" title="printCards">
/* PLEASE LEAVE THIS STYLESHEET INLINE SINCE TITLE IS NECESSARY */
@media print {
#interface {
display: none;
}
.pb {
page-break-after: always;
clear: both;
}
}
#buttonDiv,
#storyDropdown,
#iterationDropdown {
display: inline;
}
#interface, #printSection {
margin: 20px;
}
html {
background-color: #fff;
color: #000;
font: 14pt / 1.26 Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
}
body {
background-color: #fff;
margin: 0;
padding: 0;
}
.cb {
clear: both;
}
.artifact {
background-color: #fff;
border: 2px solid #000;
float: left;
height: 3.2in;
margin: 0.1in 0.1in 0.1in 0.1in;
position: relative;
overflow: hidden;
width: 4.3in;
}
.header {
border: 1px;
border-bottom-style: solid;
font-size: 18px;
height: 15%;
vertical-align: middle;
width: 4.3in;
}
#HierarchicalRequirement {
background-color:#8B4789;
color: white;
-webkit-print-color-adjust:exact;
}
#defect {
background-color:#CD3333;
color: white;
-webkit-print-color-adjust:exact;
}
#testset {
background-color:#383951;
color: white;
-webkit-print-color-adjust:exact;
}
.card-title {
font: bold 16px Genova, sans-serif;
padding-top: 0.5em;
text-align: left;
}
.description {
float: left;
font: 6pt Georgia, sans-serif;
margin: 0.25em auto 0 auto;
padding-left: 1.0em;
padding-right: 1.0em;
overflow-y: hidden;
width: 100%;
word-wrap: break-word;
}
.owner {
float: right;
height: 20%;
-webkit-print-color-adjust:exact;
}
.ownerText {
float: right;
font: 10pt / 1.26 Arial, Helvetica, sans-serif;
margin-right: 0.3em;
margin-top: 0.3em;
-webkit-print-color-adjust:exact;
}
.ownerImage {
float: right;
vertical-align:top;
-webkit-print-color-adjust:exact;
}
.storyID {
float: left;
font: 14pt / 1.26 Arial, Helvetica, sans-serif;
margin-left: 0.25em;
margin-top: 0.3em;
-webkit-print-color-adjust:exact;
}
.estimate {
font: bold 16px Genova, sans-serif;
bottom: 0.5em;
position: absolute;
right: 0.5em;
}
.release {
font: bold 16px Genova, sans-serif;
bottom: 0.5em;
position: absolute;
left: 0.5em;
}
.content {
height: 70%;
overflow: hidden;
width: 100%;
}
.footer {
border: 1px;
border-top-style: solid;
display: table-cell;
font-size: 18px;
height: 100%;
vertical-align: bottom;
width: 4.3in;
}
</style>
<script type="text/javascript">
function onLoad() {
rally.sdk.ui.AppHeader.setHelpTopic("242");
var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
var printTaskCards = new PrintTaskCards(rallyDataSource);
printTaskCards.display(dojo.body());
}
rally.addOnLoad(onLoad);
</script>
</head>
<body>
<div style="float:right" id="help"></div>
<div id="interface">
<table>
<thead id=""><tr><th style="font:700; font-size:large;">Select either iteration or enter an individual story.</th></tr></thead>
<tbody>
<tr><td id="iterationDropdown" /><td id="showDefectsCB" style="position:relative; left:5px" /></tr>
<tr><td id="storyDropdown" /><td id="buttonDiv" style="position:relative; left: 10px" /></tr>
</tbody>
</table>
</div>
<div id="printSection">
<div id="cards"></div>
</div>
</body>
</html>