issue_tracker_settings.mako
328 lines
| 10.7 KiB
| application/x-mako
|
MakoHtmlLexer
r1282 | ## snippet for displaying issue tracker settings | |||
## usage: | ||||
## <%namespace name="its" file="/base/issue_tracker_settings.mako"/> | ||||
## ${its.issue_tracker_settings_table(patterns, form_url, delete_url)} | ||||
## ${its.issue_tracker_settings_test(test_url)} | ||||
<%def name="issue_tracker_settings_table(patterns, form_url, delete_url)"> | ||||
r4111 | <% | |||
# Name/desc, pattern, issue prefix | ||||
examples = [ | ||||
( | ||||
' ', | ||||
' ', | ||||
' ', | ||||
' ' | ||||
), | ||||
( | ||||
r4498 | 'Tickets with #123 (Redmine etc)', | |||
'(?<![a-zA-Z0-9_/]{1,10}-?)(#)(?P<issue_id>\d+)', | ||||
r4111 | 'https://myissueserver.com/${repo}/issue/${issue_id}', | |||
'' | ||||
), | ||||
( | ||||
'Redmine - Alternative', | ||||
'(?:issue-)(\d+)', | ||||
'https://myissueserver.com/redmine/issue/${id}', | ||||
'' | ||||
), | ||||
( | ||||
'Redmine - Wiki', | ||||
'(?:wiki-)([a-zA-Z0-9]+)', | ||||
'http://example.org/projects/${repo_name}/wiki/${id}', | ||||
'wiki-' | ||||
), | ||||
( | ||||
'JIRA - All tickets', | ||||
r4498 | # official JIRA ticket pattern | |||
'(?<![a-zA-Z0-9_/#]-?)(?P<issue_id>[A-Z]{1,6}-(?:[1-9][0-9]{0,7}))', | ||||
'https://myjira.com/browse/${issue_id}', | ||||
r4111 | '' | |||
), | ||||
( | ||||
r4498 | 'JIRA - Single project (JRA-XXXXXXXX)', | |||
'(?<![a-zA-Z0-9_/#]-?)(?P<issue_id>JRA-(?:[1-9][0-9]{0,7}))', | ||||
r4111 | 'https://myjira.com/${issue_id}', | |||
'' | ||||
), | ||||
( | ||||
'Confluence WIKI', | ||||
'(?:conf-)([A-Z0-9]+)', | ||||
'https://example.atlassian.net/display/wiki/${id}/${repo_name}', | ||||
'CONF-', | ||||
), | ||||
( | ||||
'Pivotal Tracker', | ||||
r4199 | '(?:pivot-)(?P<project_id>\d+)-(?P<story>\d+)', | |||
r4111 | 'https://www.pivotaltracker.com/s/projects/${project_id}/stories/${story}', | |||
'PIV-', | ||||
), | ||||
( | ||||
'Trello', | ||||
r4199 | '(?:trello-)(?P<card_id>[a-zA-Z0-9]+)', | |||
r4111 | 'https://trello.com/example.com/${card_id}', | |||
'TRELLO-', | ||||
), | ||||
] | ||||
%> | ||||
r1282 | <table class="rctable issuetracker"> | |||
<tr> | ||||
<th>${_('Description')}</th> | ||||
<th>${_('Pattern')}</th> | ||||
<th>${_('Url')}</th> | ||||
r4111 | <th>${_('Extra Prefix')}</th> | |||
r1282 | <th ></th> | |||
</tr> | ||||
r4111 | % for name, pat, url, pref in examples: | |||
<tr class="it-examples" style="${'' if loop.index == 0 else 'display:none'}"> | ||||
<td class="td-issue-tracker-name issue-tracker-example">${name}</td> | ||||
<td class="td-regex issue-tracker-example">${pat}</td> | ||||
<td class="td-url issue-tracker-example">${url}</td> | ||||
<td class="td-prefix issue-tracker-example">${pref}</td> | ||||
<td> | ||||
% if loop.index == 0: | ||||
<a href="#showMore" onclick="$('.it-examples').toggle(); return false">${_('show examples')}</a> | ||||
% else: | ||||
r4974 | <a href="#copyToInput" onclick="copyToInput(this, '${h.str_json(name)}', '${h.str_json(pat)}', '${h.str_json(url)}', '${h.str_json(pref)}'); return false">copy to input</a> | |||
r4111 | % endif | |||
</td> | ||||
</tr> | ||||
% endfor | ||||
r1282 | %for uid, entry in patterns: | |||
<tr id="entry_${uid}"> | ||||
r4111 | <td class="td-issue-tracker-name issuetracker_desc"> | |||
r1282 | <span class="entry"> | |||
${entry.desc} | ||||
</span> | ||||
<span class="edit"> | ||||
${h.text('new_pattern_description_'+uid, class_='medium-inline', value=entry.desc or '')} | ||||
</span> | ||||
</td> | ||||
r4111 | <td class="td-issue-tracker-regex issuetracker_pat"> | |||
r1282 | <span class="entry"> | |||
${entry.pat} | ||||
</span> | ||||
<span class="edit"> | ||||
${h.text('new_pattern_pattern_'+uid, class_='medium-inline', value=entry.pat or '')} | ||||
</span> | ||||
</td> | ||||
<td class="td-url issuetracker_url"> | ||||
<span class="entry"> | ||||
${entry.url} | ||||
</span> | ||||
<span class="edit"> | ||||
${h.text('new_pattern_url_'+uid, class_='medium-inline', value=entry.url or '')} | ||||
</span> | ||||
</td> | ||||
<td class="td-prefix issuetracker_pref"> | ||||
<span class="entry"> | ||||
${entry.pref} | ||||
</span> | ||||
<span class="edit"> | ||||
${h.text('new_pattern_prefix_'+uid, class_='medium-inline', value=entry.pref or '')} | ||||
</span> | ||||
</td> | ||||
<td class="td-action"> | ||||
<div class="grid_edit"> | ||||
<span class="entry"> | ||||
<a class="edit_issuetracker_entry" href="">${_('Edit')}</a> | ||||
</span> | ||||
<span class="edit"> | ||||
r4041 | <input id="uid_${uid}" name="uid" type="hidden" value="${uid}"> | |||
r1282 | </span> | |||
</div> | ||||
<div class="grid_delete"> | ||||
<span class="entry"> | ||||
<a class="btn btn-link btn-danger delete_issuetracker_entry" data-desc="${entry.desc}" data-uid="${uid}"> | ||||
${_('Delete')} | ||||
</a> | ||||
</span> | ||||
<span class="edit"> | ||||
<a class="btn btn-link btn-danger edit_issuetracker_cancel" data-uid="${uid}">${_('Cancel')}</a> | ||||
</span> | ||||
</div> | ||||
</td> | ||||
</tr> | ||||
%endfor | ||||
<tr id="last-row"></tr> | ||||
</table> | ||||
<p> | ||||
<a id="add_pattern" class="link"> | ||||
${_('Add new')} | ||||
</a> | ||||
</p> | ||||
<script type="text/javascript"> | ||||
var newEntryLabel = $('label[for="new_entry"]'); | ||||
var resetEntry = function() { | ||||
newEntryLabel.text("${_('New Entry')}:"); | ||||
}; | ||||
var delete_pattern = function(entry) { | ||||
if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) { | ||||
r4041 | $.ajax({ | |||
r1282 | type: "POST", | |||
r4111 | url: "${delete_url}", | |||
r1282 | data: { | |||
'csrf_token': CSRF_TOKEN, | ||||
'uid':$(entry).data('uid') | ||||
}, | ||||
success: function(){ | ||||
r4111 | window.location.reload(); | |||
r1282 | }, | |||
error: function(data, textStatus, errorThrown){ | ||||
alert("Error while deleting entry.\nError code {0} ({1}). URL: {2}".format(data.status,data.statusText,$(entry)[0].url)); | ||||
} | ||||
}); | ||||
r2014 | } | |||
}; | ||||
r1282 | ||||
$('.delete_issuetracker_entry').on('click', function(e){ | ||||
e.preventDefault(); | ||||
delete_pattern(this); | ||||
}); | ||||
$('.edit_issuetracker_entry').on('click', function(e){ | ||||
e.preventDefault(); | ||||
$(this).parents('tr').addClass('editopen'); | ||||
}); | ||||
$('.edit_issuetracker_cancel').on('click', function(e){ | ||||
e.preventDefault(); | ||||
$(this).parents('tr').removeClass('editopen'); | ||||
// Reset to original value | ||||
var uid = $(this).data('uid'); | ||||
$('#'+uid+' input').each(function(e) { | ||||
this.value = this.defaultValue; | ||||
}); | ||||
}); | ||||
$('input#reset').on('click', function(e) { | ||||
resetEntry(); | ||||
}); | ||||
$('#add_pattern').on('click', function(e) { | ||||
addNewPatternInput(); | ||||
}); | ||||
r4111 | ||||
var copied = false; | ||||
copyToInput = function (elem, name, pat, url, pref) { | ||||
if (copied === false) { | ||||
addNewPatternInput(); | ||||
copied = true; | ||||
} | ||||
$(elem).hide(); | ||||
var load = function(text){ | ||||
return text.replace(/["]/g, "") | ||||
}; | ||||
$('#description_1').val(load(name)); | ||||
$('#pattern_1').val(load(pat)); | ||||
$('#url_1').val(load(url)); | ||||
$('#prefix_1').val(load(pref)); | ||||
} | ||||
r1282 | </script> | |||
</%def> | ||||
<%def name="issue_tracker_new_row()"> | ||||
<table id="add-row-tmpl" style="display: none;"> | ||||
<tbody> | ||||
<tr class="new_pattern"> | ||||
r4111 | <td class="td-issue-tracker-name issuetracker_desc"> | |||
r1282 | <span class="entry"> | |||
r4111 | <input class="medium-inline" id="description_##UUID##" name="new_pattern_description_##UUID##" value="##DESCRIPTION##" type="text"> | |||
r1282 | </span> | |||
</td> | ||||
r4111 | <td class="td-issue-tracker-regex issuetracker_pat"> | |||
r1282 | <span class="entry"> | |||
<input class="medium-inline" id="pattern_##UUID##" name="new_pattern_pattern_##UUID##" placeholder="Pattern" | ||||
value="##PATTERN##" type="text"> | ||||
</span> | ||||
</td> | ||||
<td class="td-url issuetracker_url"> | ||||
<span class="entry"> | ||||
<input class="medium-inline" id="url_##UUID##" name="new_pattern_url_##UUID##" placeholder="Url" value="##URL##" type="text"> | ||||
</span> | ||||
</td> | ||||
<td class="td-prefix issuetracker_pref"> | ||||
<span class="entry"> | ||||
<input class="medium-inline" id="prefix_##UUID##" name="new_pattern_prefix_##UUID##" placeholder="Prefix" value="##PREFIX##" type="text"> | ||||
</span> | ||||
</td> | ||||
<td class="td-action"> | ||||
</td> | ||||
<input id="uid_##UUID##" name="uid_##UUID##" type="hidden" value=""> | ||||
</tr> | ||||
</tbody> | ||||
</table> | ||||
</%def> | ||||
<%def name="issue_tracker_settings_test(test_url)"> | ||||
<div class="form-vertical"> | ||||
<div class="fields"> | ||||
<div class="field"> | ||||
<div class='textarea-full'> | ||||
r4111 | <textarea id="test_pattern_data" rows="12"> | |||
r4047 | This is an example text for testing issue tracker patterns. | |||
r4498 | This commit fixes ticket #451 and ticket #910, reference for JRA-401. | |||
The following tickets will get mentioned: | ||||
r4111 | #123 | |||
r4498 | #456 and PROJ-101 | |||
JRA-123 and #123 | ||||
PROJ-456 | ||||
[my artifact](http://something.com/JRA-1234-build.zip) | ||||
- #1001 | ||||
- JRA-998 | ||||
Open a pull request !101 to contribute! | ||||
r4047 | Added tag v1.3.0 for commit 0f3b629be725 | |||
Add a test pattern here and hit preview to see the link. | ||||
r1282 | </textarea> | |||
</div> | ||||
</div> | ||||
</div> | ||||
<div class="test_pattern_preview"> | ||||
<div id="test_pattern" class="btn btn-small" >${_('Preview')}</div> | ||||
<p>${_('Test Pattern Preview')}</p> | ||||
r4041 | <div id="test_pattern_result" style="white-space: pre-wrap"></div> | |||
r1282 | </div> | |||
</div> | ||||
<script type="text/javascript"> | ||||
$('#test_pattern').on('click', function(e) { | ||||
$.ajax({ | ||||
type: "POST", | ||||
url: "${test_url}", | ||||
data: { | ||||
'test_text': $('#test_pattern_data').val(), | ||||
'csrf_token': CSRF_TOKEN | ||||
}, | ||||
success: function(data){ | ||||
$('#test_pattern_result').html(data); | ||||
r4026 | tooltipActivate(); | |||
r1282 | }, | |||
error: function(jqXHR, textStatus, errorThrown){ | ||||
$('#test_pattern_result').html('Error: ' + errorThrown); | ||||
} | ||||
}); | ||||
$('#test_pattern_result').show(); | ||||
}); | ||||
</script> | ||||
</%def> | ||||