Last active
August 29, 2015 14:18
-
-
Save peschee/3db1a4ab69ad72e79740 to your computer and use it in GitHub Desktop.
JIRA bug report update script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
(function ($) { | |
$(function () { | |
var descriptionTemplate = "What URL were you on? Who were you logged in as? Is there anything else about your environment that is important (Browser, Browser Version)?\n\nh3. What did you expected it to do?\n\nh3. What did it actually do?\n\nh3. What are the detailed steps to recreate this behavior?\n\n# Step 1\n# Step 2\n# Step 3\n# ..."; | |
var updateDescription = function updateDescription($issueTypeField, $description) { | |
if ($issueTypeField.length > 0 && $description.length > 0) { | |
var issueType = $issueTypeField.get('selector') === '#issue-create-issue-type' ? $issueTypeField.html() : $issueTypeField.val(); | |
// Update description | |
if (issueType === 'Bug' && !$description.val()) { | |
$description.val(descriptionTemplate); | |
} | |
// Reset | |
else if (issueType !== 'Bug' && $description.val() === descriptionTemplate) { | |
$description.val(''); | |
} | |
} | |
}; | |
// Update description field on issue type field change | |
$(document).on('change', '#issuetype-field', function () { | |
updateDescription($(this), $('#description')); | |
}); | |
// Update description initially | |
var $staticIssueType = $('#issue-create-issue-type'); | |
var $issueTypeDropdown = $('#issuetype-field'); | |
var $targetInitialIssueType = $staticIssueType.length > 0 ? $staticIssueType : $issueTypeDropdown; | |
updateDescription($targetInitialIssueType, $('#description')); | |
}); | |
})(jQuery); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment