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