Created
January 10, 2014 14:23
-
-
Save icio/8353917 to your computer and use it in GitHub Desktop.
Useful for when you have to move from one JIRA workflow to another but don't want to repeat the mapping for every fucking issue type.
This file contains 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
/** | |
* Duplicate the mapping of Current Status to New Status from the first | |
* issue type to the subsequent issue types. | |
*/ | |
var tbody = document.getElementById('workflow-mapping-table').querySelector('tbody'); | |
var cell = tbody.appendChild(document.createElement('tr')).appendChild(document.createElement('td')); | |
cell.setAttribute("colspan", 3); | |
cell.style.textAlign = "right"; | |
var button = cell.appendChild(document.createElement('a')); | |
button.className = 'aui-button'; | |
button.appendChild(document.createTextNode("Duplicate mapping ↓")); | |
button.onclick = function() { | |
Array.prototype.slice.call(tbody.querySelectorAll('select[name^=mapping]')) | |
.map(function(select) { return select.name.split('_').pop(); }) | |
.forEach(function(id) { | |
var query='select[name^=mapping][name$=_'+id+']', | |
first = document.querySelector(query); | |
Array.prototype.splice.call(document.querySelectorAll(query), 1) | |
.forEach(function(select) { | |
select.selectedIndex = first.selectedIndex; | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment