Skip to content

Instantly share code, notes, and snippets.

@icio
Created January 10, 2014 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icio/8353917 to your computer and use it in GitHub Desktop.
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.
/**
* 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