-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
331 lines (273 loc) · 10.6 KB
/
index.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>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-MCDWDNJ');</script>
<!-- End Google Tag Manager -->
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Scrum Card Printer</title>
<style>
#settings {
margin-top: 20px;
}
.scrumCardRow {
page-break-after: always;
}
.row {
padding-bottom: 5px;
border-bottom: 2px dashed gray;
}
.scrumcardContainer {
padding: 10px;
}
.scrumcard {
border: 1px solid #bcbcbc;
border-left-width: 5px;
padding: 15px;
height: 325px;
}
h2 {
font-size: 1.5rem;
min-height: 70px;
}
.card-text {
font-size: 80%;
}
.cardKey {
color: #707070;
margin-bottom: 10px;
}
.cardBottom {
position: absolute;
bottom: 20px;
width: 76%;
background-color: white;
}
.epicLabel {
border-radius: 3px;
display: inline-block;
margin: 0 5px 0 0;
padding: 5px;
max-width: 185px;
font-size: 0.7rem;
}
.details {
overflow: hidden;
font-size: 0.7rem;
}
span.ghx-label-1 {
color: #fff;
background-color: #815b3a;
}
div.ghx-label-1 {
border-left-color: #815b3a;
}
span.ghx-label-3 {
color: #fff;
background-color: #d39c3f;
}
div.ghx-label-3 {
border-left-color: #d39c3f;
}
span.ghx-label-4 {
color: #fff;
background-color: #3b7fc4;
}
div.ghx-label-4 {
border-left-color: #3b7fc4;
}
span.ghx-label-5 {
color: #fff;
background-color: #4a6785;
}
div.ghx-label-5 {
border-left-color: #4a6785;
}
span.ghx-label-6 {
color: #fff;
background-color: #8eb021;
}
div.ghx-label-6 {
border-left-color: #8eb021;
}
span.ghx-label-7 {
color: #fff;
background-color: #ac707a;
}
div.ghx-label-7 {
border-left-color: #ac707a;
}
span.ghx-label-8 {
color: #fff;
background-color: #654982;
}
div.ghx-label-8 {
border-left-color: #654982;
}
span.ghx-label-9 {
color: #fff;
background-color: #f15c75;
}
div.ghx-label-9 {
border-left-color: #f15c75;
}
</style>
<style type="text/css" media="print">
@page {
size: landscape;
}
</style>
</head>
<body>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-MCDWDNJ"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div class="container" id="settings">
<!-- This was quickly written, pardon the mess :) -->
<div class="card bg-light">
<div class="card-body">
<h5 class="card-title">Scrumcard Printer</h5>
<p class="card-text">
This is a tool to quickly create printable Scrum Cards from your Jira Tickets.
</p>
<h6 class="card-subtitle mb-2 text-muted">How to use</h6>
<p class="card-text">
Export a CSV file of your Jira tickets. Epics will not be printed. In order to link the epics to the
story, do include them in your export. Export to CSV with the folowing columns:
</p>
<ul class="card-text">
<li>Summary</li>
<li>Issue key</li>
<li>Description</li>
<li>Custom field (Epic Link)</li>
<li>Custom field (Epic Name)</li>
<li>Custom field (Epic Colour)</li>
</ul>
<br>
<h6 class="card-subtitle mb-2 text-muted">JQL Example</h6>
<p class="card-text">
Including project, filtered by epic and status, but also including the epic itself so we can extract
color and title.<br>
<code>project = PROJ AND status in (Open, Backlog) AND "Epic Link" in (PROJ-2179, PROJ-1807, PROJ-2432, PROJ-2495, PROJ-2452, PROJ-2502, PROJ-2468, PROJ-1783, PROJ-2409) or issueKey in (PROJ-2179, PROJ-1807, PROJ-2432, PROJ-2495, PROJ-2452, PROJ-2502, PROJ-2468, PROJ-1783, PROJ-2409)</code>
</p>
<br>
<h6 class="card-subtitle mb-2 text-muted">Create Scrumcards</h6>
<small>Your file will not be uploaded, no files will leave your computer. See the source at <a href='https://github.com/WesleyE/ScrumCards'>Github</a>.</small><br>
<input type="file" id="file">
</div>
</div>
<div id="template" style="display: none;">
<div class="row" id="templateRow">
</div>
<div class="col-md-6 scrumcardContainer" id="templateCard">
<div class="scrumcard">
<small class="cardKey">Summary</small>
<h2 class="cardTitle">Some Card Title</h2>
<p class="details"></p>
<div class="cardBottom">
<span class="epicLabel"></span>
</div>
</div>
</div>
</div>
</div>
<div class="container" id="cardContainer">
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/papaparse.min.js"></script>
<script>
String.prototype.trunc =
function (n, useWordBoundary) {
if (this.length <= n) { return this; }
var subString = this.substr(0, n - 1);
return (useWordBoundary
? subString.substr(0, subString.lastIndexOf(' '))
: subString) + "…";
};
$(document).ready(function () {
window.onbeforeprint = function () {
$("#settings").hide();
};
window.onafterprint = function () {
$("#settings").show();
};
document.querySelector("#file").addEventListener('change', fileChosen, false);
});
function fileChosen(evt) {
$("#file").parse({
config: {
header: true,
complete: function (results, file) {
console.log("This file done:", file, results);
createScrumCards(results.data);
}
},
complete: function () {
console.log("All files done!");
}
});
}
function createScrumCards(data) {
var epicList = [];
var storyList = [];
// Create Epic list
for (var i = 0; i < data.length; i++) {
if (data[i]['Issue Type'] === 'Epic') {
epicList.push(data[i]);
} else {
storyList.push(data[i]);
}
}
for (var i = 0; i < storyList.length; i++) {
if (i % 2 === 0) {
var templateRowClone = $('#templateRow').clone();
$(templateRowClone).removeAttr('id');
$('#cardContainer').append(templateRowClone);
}
if (i % 4 === 0) {
$(templateRowClone).addClass('scrumCardRow');
}
var templateCardClone = $('#templateCard').clone();
$(templateCardClone).removeAttr('id');
$(templateCardClone).find('.cardTitle').text(storyList[i].Summary);
$(templateCardClone).find('.cardKey').text(storyList[i]['Issue key']);
var detailText = storyList[i]['Description'];
detailText = detailText.replace(/\{.*\}/g, '');
detailText = detailText.replace(/\n\s{1,}/g, '<br><br>');
detailText = detailText.trunc(350, true);
$(templateCardClone).find('.details').html(detailText); // Truncate to a good length
// Find the linked Epic
var epic = epicList.find(obj => {
return obj['Issue key'] === storyList[i]['Custom field (Epic Link)'];
});
if (epic) {
$(templateCardClone).find('.epicLabel').text(epic['Custom field (Epic Name)']);
$(templateCardClone).find('.epicLabel').addClass(epic['Custom field (Epic Colour)']);
$(templateCardClone).find('div').first().addClass(epic['Custom field (Epic Colour)']);
}
$(templateRowClone).append(templateCardClone);
}
}
</script>
</body>
</html>