Show More
@@ -1,321 +1,321 b'' | |||
|
1 | 1 | ## snippet for displaying issue tracker settings |
|
2 | 2 | ## usage: |
|
3 | 3 | ## <%namespace name="its" file="/base/issue_tracker_settings.mako"/> |
|
4 | 4 | ## ${its.issue_tracker_settings_table(patterns, form_url, delete_url)} |
|
5 | 5 | ## ${its.issue_tracker_settings_test(test_url)} |
|
6 | 6 | |
|
7 | 7 | <%def name="issue_tracker_settings_table(patterns, form_url, delete_url)"> |
|
8 | 8 | <% |
|
9 | 9 | # Name/desc, pattern, issue prefix |
|
10 | 10 | examples = [ |
|
11 | 11 | ( |
|
12 | 12 | ' ', |
|
13 | 13 | ' ', |
|
14 | 14 | ' ', |
|
15 | 15 | ' ' |
|
16 | 16 | ), |
|
17 | 17 | |
|
18 | 18 | ( |
|
19 | 19 | 'Redmine', |
|
20 | 20 | '(^#|\s#)(?P<issue_id>\d+)', |
|
21 | 21 | 'https://myissueserver.com/${repo}/issue/${issue_id}', |
|
22 | 22 | '' |
|
23 | 23 | ), |
|
24 | 24 | |
|
25 | 25 | ( |
|
26 | 26 | 'Redmine - Alternative', |
|
27 | 27 | '(?:issue-)(\d+)', |
|
28 | 28 | 'https://myissueserver.com/redmine/issue/${id}', |
|
29 | 29 | '' |
|
30 | 30 | ), |
|
31 | 31 | |
|
32 | 32 | ( |
|
33 | 33 | 'Redmine - Wiki', |
|
34 | 34 | '(?:wiki-)([a-zA-Z0-9]+)', |
|
35 | 35 | 'http://example.org/projects/${repo_name}/wiki/${id}', |
|
36 | 36 | 'wiki-' |
|
37 | 37 | ), |
|
38 | 38 | |
|
39 | 39 | ( |
|
40 | 40 | 'JIRA - All tickets', |
|
41 | 41 | '(^|\s\w+-\d+)', |
|
42 | 42 | 'https://myjira.com/browse/${id}', |
|
43 | 43 | '' |
|
44 | 44 | ), |
|
45 | 45 | |
|
46 | 46 | ( |
|
47 | 47 | 'JIRA - Project (JRA)', |
|
48 | 48 | '(?:(^|\s)(?P<issue_id>(?:JRA-|JRA-)(?:\d+)))', |
|
49 | 49 | 'https://myjira.com/${issue_id}', |
|
50 | 50 | '' |
|
51 | 51 | ), |
|
52 | 52 | |
|
53 | 53 | ( |
|
54 | 54 | 'Confluence WIKI', |
|
55 | 55 | '(?:conf-)([A-Z0-9]+)', |
|
56 | 56 | 'https://example.atlassian.net/display/wiki/${id}/${repo_name}', |
|
57 | 57 | 'CONF-', |
|
58 | 58 | ), |
|
59 | 59 | |
|
60 | 60 | ( |
|
61 | 61 | 'Pivotal Tracker', |
|
62 | '(?:pivot-)(?<project_id>\d+)-(?<story>\d+)', | |
|
62 | '(?:pivot-)(?P<project_id>\d+)-(?P<story>\d+)', | |
|
63 | 63 | 'https://www.pivotaltracker.com/s/projects/${project_id}/stories/${story}', |
|
64 | 64 | 'PIV-', |
|
65 | 65 | ), |
|
66 | 66 | |
|
67 | 67 | ( |
|
68 | 68 | 'Trello', |
|
69 | '(?:trello-)(?<card_id>[a-zA-Z0-9]+)', | |
|
69 | '(?:trello-)(?P<card_id>[a-zA-Z0-9]+)', | |
|
70 | 70 | 'https://trello.com/example.com/${card_id}', |
|
71 | 71 | 'TRELLO-', |
|
72 | 72 | ), |
|
73 | 73 | ] |
|
74 | 74 | %> |
|
75 | 75 | |
|
76 | 76 | <table class="rctable issuetracker"> |
|
77 | 77 | <tr> |
|
78 | 78 | <th>${_('Description')}</th> |
|
79 | 79 | <th>${_('Pattern')}</th> |
|
80 | 80 | <th>${_('Url')}</th> |
|
81 | 81 | <th>${_('Extra Prefix')}</th> |
|
82 | 82 | <th ></th> |
|
83 | 83 | </tr> |
|
84 | 84 | % for name, pat, url, pref in examples: |
|
85 | 85 | <tr class="it-examples" style="${'' if loop.index == 0 else 'display:none'}"> |
|
86 | 86 | <td class="td-issue-tracker-name issue-tracker-example">${name}</td> |
|
87 | 87 | <td class="td-regex issue-tracker-example">${pat}</td> |
|
88 | 88 | <td class="td-url issue-tracker-example">${url}</td> |
|
89 | 89 | <td class="td-prefix issue-tracker-example">${pref}</td> |
|
90 | 90 | <td> |
|
91 | 91 | % if loop.index == 0: |
|
92 | 92 | <a href="#showMore" onclick="$('.it-examples').toggle(); return false">${_('show examples')}</a> |
|
93 | 93 | % else: |
|
94 | 94 | <a href="#copyToInput" onclick="copyToInput(this, '${h.json.dumps(name)}', '${h.json.dumps(pat)}', '${h.json.dumps(url)}', '${h.json.dumps(pref)}'); return false">copy to input</a> |
|
95 | 95 | % endif |
|
96 | 96 | </td> |
|
97 | 97 | </tr> |
|
98 | 98 | % endfor |
|
99 | 99 | |
|
100 | 100 | %for uid, entry in patterns: |
|
101 | 101 | <tr id="entry_${uid}"> |
|
102 | 102 | <td class="td-issue-tracker-name issuetracker_desc"> |
|
103 | 103 | <span class="entry"> |
|
104 | 104 | ${entry.desc} |
|
105 | 105 | </span> |
|
106 | 106 | <span class="edit"> |
|
107 | 107 | ${h.text('new_pattern_description_'+uid, class_='medium-inline', value=entry.desc or '')} |
|
108 | 108 | </span> |
|
109 | 109 | </td> |
|
110 | 110 | <td class="td-issue-tracker-regex issuetracker_pat"> |
|
111 | 111 | <span class="entry"> |
|
112 | 112 | ${entry.pat} |
|
113 | 113 | </span> |
|
114 | 114 | <span class="edit"> |
|
115 | 115 | ${h.text('new_pattern_pattern_'+uid, class_='medium-inline', value=entry.pat or '')} |
|
116 | 116 | </span> |
|
117 | 117 | </td> |
|
118 | 118 | <td class="td-url issuetracker_url"> |
|
119 | 119 | <span class="entry"> |
|
120 | 120 | ${entry.url} |
|
121 | 121 | </span> |
|
122 | 122 | <span class="edit"> |
|
123 | 123 | ${h.text('new_pattern_url_'+uid, class_='medium-inline', value=entry.url or '')} |
|
124 | 124 | </span> |
|
125 | 125 | </td> |
|
126 | 126 | <td class="td-prefix issuetracker_pref"> |
|
127 | 127 | <span class="entry"> |
|
128 | 128 | ${entry.pref} |
|
129 | 129 | </span> |
|
130 | 130 | <span class="edit"> |
|
131 | 131 | ${h.text('new_pattern_prefix_'+uid, class_='medium-inline', value=entry.pref or '')} |
|
132 | 132 | </span> |
|
133 | 133 | </td> |
|
134 | 134 | <td class="td-action"> |
|
135 | 135 | <div class="grid_edit"> |
|
136 | 136 | <span class="entry"> |
|
137 | 137 | <a class="edit_issuetracker_entry" href="">${_('Edit')}</a> |
|
138 | 138 | </span> |
|
139 | 139 | <span class="edit"> |
|
140 | 140 | <input id="uid_${uid}" name="uid" type="hidden" value="${uid}"> |
|
141 | 141 | </span> |
|
142 | 142 | </div> |
|
143 | 143 | <div class="grid_delete"> |
|
144 | 144 | <span class="entry"> |
|
145 | 145 | <a class="btn btn-link btn-danger delete_issuetracker_entry" data-desc="${entry.desc}" data-uid="${uid}"> |
|
146 | 146 | ${_('Delete')} |
|
147 | 147 | </a> |
|
148 | 148 | </span> |
|
149 | 149 | <span class="edit"> |
|
150 | 150 | <a class="btn btn-link btn-danger edit_issuetracker_cancel" data-uid="${uid}">${_('Cancel')}</a> |
|
151 | 151 | </span> |
|
152 | 152 | </div> |
|
153 | 153 | </td> |
|
154 | 154 | </tr> |
|
155 | 155 | %endfor |
|
156 | 156 | <tr id="last-row"></tr> |
|
157 | 157 | </table> |
|
158 | 158 | <p> |
|
159 | 159 | <a id="add_pattern" class="link"> |
|
160 | 160 | ${_('Add new')} |
|
161 | 161 | </a> |
|
162 | 162 | </p> |
|
163 | 163 | |
|
164 | 164 | <script type="text/javascript"> |
|
165 | 165 | var newEntryLabel = $('label[for="new_entry"]'); |
|
166 | 166 | |
|
167 | 167 | var resetEntry = function() { |
|
168 | 168 | newEntryLabel.text("${_('New Entry')}:"); |
|
169 | 169 | }; |
|
170 | 170 | |
|
171 | 171 | var delete_pattern = function(entry) { |
|
172 | 172 | if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) { |
|
173 | 173 | $.ajax({ |
|
174 | 174 | type: "POST", |
|
175 | 175 | url: "${delete_url}", |
|
176 | 176 | data: { |
|
177 | 177 | 'csrf_token': CSRF_TOKEN, |
|
178 | 178 | 'uid':$(entry).data('uid') |
|
179 | 179 | }, |
|
180 | 180 | success: function(){ |
|
181 | 181 | window.location.reload(); |
|
182 | 182 | }, |
|
183 | 183 | error: function(data, textStatus, errorThrown){ |
|
184 | 184 | alert("Error while deleting entry.\nError code {0} ({1}). URL: {2}".format(data.status,data.statusText,$(entry)[0].url)); |
|
185 | 185 | } |
|
186 | 186 | }); |
|
187 | 187 | } |
|
188 | 188 | }; |
|
189 | 189 | |
|
190 | 190 | $('.delete_issuetracker_entry').on('click', function(e){ |
|
191 | 191 | e.preventDefault(); |
|
192 | 192 | delete_pattern(this); |
|
193 | 193 | }); |
|
194 | 194 | |
|
195 | 195 | $('.edit_issuetracker_entry').on('click', function(e){ |
|
196 | 196 | e.preventDefault(); |
|
197 | 197 | $(this).parents('tr').addClass('editopen'); |
|
198 | 198 | }); |
|
199 | 199 | |
|
200 | 200 | $('.edit_issuetracker_cancel').on('click', function(e){ |
|
201 | 201 | e.preventDefault(); |
|
202 | 202 | $(this).parents('tr').removeClass('editopen'); |
|
203 | 203 | // Reset to original value |
|
204 | 204 | var uid = $(this).data('uid'); |
|
205 | 205 | $('#'+uid+' input').each(function(e) { |
|
206 | 206 | this.value = this.defaultValue; |
|
207 | 207 | }); |
|
208 | 208 | }); |
|
209 | 209 | |
|
210 | 210 | $('input#reset').on('click', function(e) { |
|
211 | 211 | resetEntry(); |
|
212 | 212 | }); |
|
213 | 213 | |
|
214 | 214 | $('#add_pattern').on('click', function(e) { |
|
215 | 215 | addNewPatternInput(); |
|
216 | 216 | }); |
|
217 | 217 | |
|
218 | 218 | var copied = false; |
|
219 | 219 | copyToInput = function (elem, name, pat, url, pref) { |
|
220 | 220 | if (copied === false) { |
|
221 | 221 | addNewPatternInput(); |
|
222 | 222 | copied = true; |
|
223 | 223 | } |
|
224 | 224 | $(elem).hide(); |
|
225 | 225 | var load = function(text){ |
|
226 | 226 | return text.replace(/["]/g, "") |
|
227 | 227 | }; |
|
228 | 228 | $('#description_1').val(load(name)); |
|
229 | 229 | $('#pattern_1').val(load(pat)); |
|
230 | 230 | $('#url_1').val(load(url)); |
|
231 | 231 | $('#prefix_1').val(load(pref)); |
|
232 | 232 | |
|
233 | 233 | } |
|
234 | 234 | |
|
235 | 235 | </script> |
|
236 | 236 | </%def> |
|
237 | 237 | |
|
238 | 238 | <%def name="issue_tracker_new_row()"> |
|
239 | 239 | <table id="add-row-tmpl" style="display: none;"> |
|
240 | 240 | <tbody> |
|
241 | 241 | <tr class="new_pattern"> |
|
242 | 242 | <td class="td-issue-tracker-name issuetracker_desc"> |
|
243 | 243 | <span class="entry"> |
|
244 | 244 | <input class="medium-inline" id="description_##UUID##" name="new_pattern_description_##UUID##" value="##DESCRIPTION##" type="text"> |
|
245 | 245 | </span> |
|
246 | 246 | </td> |
|
247 | 247 | <td class="td-issue-tracker-regex issuetracker_pat"> |
|
248 | 248 | <span class="entry"> |
|
249 | 249 | <input class="medium-inline" id="pattern_##UUID##" name="new_pattern_pattern_##UUID##" placeholder="Pattern" |
|
250 | 250 | value="##PATTERN##" type="text"> |
|
251 | 251 | </span> |
|
252 | 252 | </td> |
|
253 | 253 | <td class="td-url issuetracker_url"> |
|
254 | 254 | <span class="entry"> |
|
255 | 255 | <input class="medium-inline" id="url_##UUID##" name="new_pattern_url_##UUID##" placeholder="Url" value="##URL##" type="text"> |
|
256 | 256 | </span> |
|
257 | 257 | </td> |
|
258 | 258 | <td class="td-prefix issuetracker_pref"> |
|
259 | 259 | <span class="entry"> |
|
260 | 260 | <input class="medium-inline" id="prefix_##UUID##" name="new_pattern_prefix_##UUID##" placeholder="Prefix" value="##PREFIX##" type="text"> |
|
261 | 261 | </span> |
|
262 | 262 | </td> |
|
263 | 263 | <td class="td-action"> |
|
264 | 264 | </td> |
|
265 | 265 | <input id="uid_##UUID##" name="uid_##UUID##" type="hidden" value=""> |
|
266 | 266 | </tr> |
|
267 | 267 | </tbody> |
|
268 | 268 | </table> |
|
269 | 269 | </%def> |
|
270 | 270 | |
|
271 | 271 | <%def name="issue_tracker_settings_test(test_url)"> |
|
272 | 272 | <div class="form-vertical"> |
|
273 | 273 | <div class="fields"> |
|
274 | 274 | <div class="field"> |
|
275 | 275 | <div class='textarea-full'> |
|
276 | 276 | <textarea id="test_pattern_data" rows="12"> |
|
277 | 277 | This is an example text for testing issue tracker patterns. |
|
278 | 278 | This commit fixes ticket #451 and ticket #910. |
|
279 | 279 | Following tickets will get mentioned: |
|
280 | 280 | #123 |
|
281 | 281 | #456 |
|
282 | 282 | JRA-123 |
|
283 | 283 | JRA-456 |
|
284 | 284 | Open a pull request !101 to contribute ! |
|
285 | 285 | Added tag v1.3.0 for commit 0f3b629be725 |
|
286 | 286 | |
|
287 | 287 | Add a test pattern here and hit preview to see the link. |
|
288 | 288 | </textarea> |
|
289 | 289 | </div> |
|
290 | 290 | </div> |
|
291 | 291 | </div> |
|
292 | 292 | <div class="test_pattern_preview"> |
|
293 | 293 | <div id="test_pattern" class="btn btn-small" >${_('Preview')}</div> |
|
294 | 294 | <p>${_('Test Pattern Preview')}</p> |
|
295 | 295 | <div id="test_pattern_result" style="white-space: pre-wrap"></div> |
|
296 | 296 | </div> |
|
297 | 297 | </div> |
|
298 | 298 | |
|
299 | 299 | <script type="text/javascript"> |
|
300 | 300 | $('#test_pattern').on('click', function(e) { |
|
301 | 301 | $.ajax({ |
|
302 | 302 | type: "POST", |
|
303 | 303 | url: "${test_url}", |
|
304 | 304 | data: { |
|
305 | 305 | 'test_text': $('#test_pattern_data').val(), |
|
306 | 306 | 'csrf_token': CSRF_TOKEN |
|
307 | 307 | }, |
|
308 | 308 | success: function(data){ |
|
309 | 309 | $('#test_pattern_result').html(data); |
|
310 | 310 | tooltipActivate(); |
|
311 | 311 | }, |
|
312 | 312 | error: function(jqXHR, textStatus, errorThrown){ |
|
313 | 313 | $('#test_pattern_result').html('Error: ' + errorThrown); |
|
314 | 314 | } |
|
315 | 315 | }); |
|
316 | 316 | $('#test_pattern_result').show(); |
|
317 | 317 | }); |
|
318 | 318 | </script> |
|
319 | 319 | </%def> |
|
320 | 320 | |
|
321 | 321 |
General Comments 0
You need to be logged in to leave comments.
Login now