I am trying to create a button on the create issue screen using a web resource.
Can anyone help me understand what I am missing or doing wrong ?
I am trying to access the script from the web resource:
AJS.toInit(function() {
function addButton() {
const createIssueDialog = document.querySelector('#create-issue-dialog');
const descriptionField = document.querySelector('#description');
if (descriptionField && createIssueDialog) {
console.log('Description field found');
const createIssueButton = document.createElement('button');
createIssueButton.innerHTML = 'Log to console';
createIssueButton.style.display = 'block';
createIssueButton.style.marginTop = '10px';
createIssueButton.style.backgroundColor = 'red';
createIssueButton.onclick = function() {
console.log('create issue button clicked');
};
descriptionField.parentNode.insertBefore(createIssueButton, descriptionField.nextSibling);
} else {
console.log('Description field not found');
}
}
if (document.querySelector('#create-issue-dialog')) {
addButton();
}
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {
if (context.closest('#create-issue-dialog').length) {
addButton();
}
});
});