Skip to content

Instantly share code, notes, and snippets.

@ThatGuyCND
Last active May 4, 2016 21:03
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 ThatGuyCND/0081dd22847b1247c6aa to your computer and use it in GitHub Desktop.
Save ThatGuyCND/0081dd22847b1247c6aa to your computer and use it in GitHub Desktop.
UserScript for Jira Story templates
/*jshint -W043 */
// ==UserScript==
// @name Jira Story templates
// @namespace https://gist.github.com/ThatGuyCND/0081dd22847b1247c6aa
// @description Provides a UI Dropdown for selecting the type of deliverable that provides an appropriate template for acceptance criteria.
// @include https://backlog.acquia.com/secure/*
// @version 1
// @grant none
// ==/UserScript==
// window.addEventListener("load", function(e) {
// // @todo add init call
// }, false);
var templateSelect = document.createElement('div'),
templateSelectAttributes = {
class : 'field-group'
},
selectLabel = document.createElement('label'),
selectLabelAttributes = {
for : 'input-description-template-select',
value : 'Issue Template: '
},
selectList = document.createElement('select'),
selectListAttributes = {
class : 'select cf-select',
id : 'input-description-template-select',
name : 'input-description-template-select'
},
attribute,
selectListOptions = {
none: ' -- None -- ',
default : 'Default',
research : 'UX Research',
prototype : 'Interactive Prototype',
pattern : 'Design Language Pattern',
component : 'Elemental Component'
},
option,
formContainer = document.querySelectorAll('form#issue-create'),
formInputDescription = document.querySelectorAll('form#issue-create textarea#description'),
summaries = {
none: null,
default : 'h3. Problem/Motivation \n\n\nh3. Proposed resolution \n\n\nh3. Remaining tasks \n\n\nh3. User interface changes \n\n\nh3. API changes \n\n\nh3. Data model changes',
research : null,
prototype : null,
pattern : null,
component : 'h3. Problem/Motivation: \n< thorough description > \n\nh3. Proposed Resolution: \n * \n\nh3. Functional Constraints: \n * \n\nh3. Remaining Tasks: \n * link design artifact [UX-] story(ies) \n * link functional specification [Confluence Page] \n * link workflow and IA wireframe story(ies) \n\nh3. MVP Deliverable: \n * \n\nh3. [Non-MVP] Future Iterations: \n * \n\nh3. Acceptance Criteria: \n< describe task’s deliverable >'
};
function elementSetAttributes (target, list) {
for (attribute in list) {
target.setAttribute(attribute, list[attribute]);
}
}
elementSetAttributes(selectLabel, selectLabelAttributes);
elementSetAttributes(selectList, selectListAttributes);
elementSetAttributes(templateSelect, templateSelectAttributes);
selectLabel.innerHTML = selectLabelAttributes.value;
// Add options to select element.
var firstOption = true;
for (option in selectListOptions) {
if (firstOption) {
var opt = new Option(selectListOptions[option], option, true, true);
firstOption = false;
} else {
var opt = new Option(selectListOptions[option], option, false, false);
}
selectList.appendChild(opt);
}
// Add eventListener callback for select element.
selectList.addEventListener('change', function (event) {
var $this = event,
value = $this.target.value;
formInputDescription[0].value = summaries[value];
});
templateSelect.appendChild(selectLabel);
templateSelect.appendChild(selectList);
// Inject new form element into the DOM.
formInputDescription[0].parentElement.appendChild(templateSelect);
@kengquiP
Copy link

Default template
Not sure we need "remaining tasks" and "user interface changes".
Eric, can you explain the rationale?
"User interface changes" - do not want the writer of the story to start designing.....
MPV or long term or both

Research
May be we need a template - Consult Melissa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment