Skip to content

Commit

Permalink
update for backlog page
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Baker committed May 28, 2019
1 parent f81a343 commit 99b17c6
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
26 changes: 26 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ const deleteableElements = [
'.remaininghours'
];

const customStories = [
{
subject: 'Tech Work',
type: 3,
storyPoints: '1.0'
},
{
subject: 'Chapter work',
type: 3
},
{
subject: 'Gold Card',
type: 10,
storyPoints: '1.0'
},
{
subject: 'Retro Action',
type: 11,
storyPoints: '1.0'
},
{
subject: 'Who is doing the next retro?',
type: 11
}
]

const customButtons = [
{
button: '👍',
Expand Down
10 changes: 10 additions & 0 deletions content.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
cursor: pointer;
}

.add-stories-button {
margin: 0 0 10px;
background: linear-gradient(#EEE, #EDD5EE);
border: 0;
cursor: pointer;
border-radius: 3px;
padding: 5px;
font-size: 1.1em;
}

.has-warning:after {
content: ' ⚠️';
}
Expand Down
45 changes: 44 additions & 1 deletion content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function init() {
// Redirect to taskboard from issues
if(config.options.redirectIssues &&
window.location.href.match(/.*\/(.*)$/)[1] === 'issues') {

window.location.replace(config.getPath('taskboard'));
}

Expand All @@ -25,6 +24,50 @@ function init() {
addElements('issue', addDeleteButton);
checkDateTickets();
}, 5000);

if(window.location.href.indexOf('master_backlog') > -1) {
window.setTimeout(initBacklogPage, 1000);
}
}

function initBacklogPage() {
const backlog = document.getElementById('sprint_backlogs_container');
const button = document.createElement('button');
button.className = 'add-stories-button';
button.innerHTML = `Add stuff`;
button.onclick = injectBaseStories;

backlog.insertBefore(button, backlog.firstChild);
}

function injectBaseStories() {
customStories.forEach(injectBaseStory);
}

function storyAlreadyThere(subject) {
const stories = document.querySelectorAll('#sprint_backlogs_container .story_field[fieldtype="textarea"]');
return ![...stories].every(story => story.innerHTML.indexOf(subject) === -1);
}

function injectBaseStory(story) {
const { subject, type, storyPoints } = story;

if (storyAlreadyThere(subject)) return;

const newStoryButton = document.querySelector('.add_new_story.project_id_32');
const mouseupEvent = new MouseEvent('mouseup', {
view: window, cancelable: true, bubbles: true
});

newStoryButton.dispatchEvent(mouseupEvent);

document.querySelector('textarea[name="subject"]').value = subject;
if (type)
document.querySelector('select[name="tracker_id"]').value = type;
if (storyPoints)
document.querySelector('select[name="story_points"]').value = storyPoints;

document.querySelector('.edit-actions .save').click();
}

function checkDateTickets() {
Expand Down

0 comments on commit 99b17c6

Please sign in to comment.