Skip to content

Instantly share code, notes, and snippets.

@paulbremer
Last active September 1, 2015 12:08
Show Gist options
  • Save paulbremer/2a3d973346bcf4a0c383 to your computer and use it in GitHub Desktop.
Save paulbremer/2a3d973346bcf4a0c383 to your computer and use it in GitHub Desktop.
Redmine Plus
// ==UserScript==
// @name Redmine Plus
// @namespace
// @version 0.5
// @description redmine+
// @match https://redmine.buyways.nl/rb/taskboards/*
// @copyright 2014+, Paul Bremer
// ==/UserScript==
var reload = true;
// Load jQuery
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.src= '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js';
head.appendChild(script);
// Update css
$('.story .subject').css('height','43px');
// Filter empty elements after trimming
$('.story-swimlane td').filter(function() {
return $.trim($(this).html()) === "";
}).addClass('swimlane-empty');
// block ON HOLD tasks
$('.story .subject').each(function(i,el){if($(el).text().match(/ON\s?HOLD/g)){$(el).closest('tr').addClass('on-hold')}});
$('tr.on-hold').css('background', '#E14A2B').appendTo('#tasks > tbody');
// For each story check status, if status is F (feedback) change backgroundcolor and move to bottom
$('.story-swimlane').each(function( index ) {
var status = $( this ).text().match(/Status:\s?([A-Z\d]+)/);
if (status[1] == 'F') {
$(this).css('background-color','#DFDCA1');
$(this).appendTo('#tasks > tbody');
}
});
// For each story check status, if status is R (resolved) change backgroundcolor and move to bottom
$('.story-swimlane').each(function( index ) {
var status = $( this ).text().match(/Status:\s?([A-Z\d]+)/);
if (status[1] == 'R') {
$(this).css('background-color','#B8B8B8');
$(this).appendTo('#tasks > tbody');
}
});
// Stories that have class closed get backgroundcolor and are moved to bottom of the board
$('.story.closed').closest('.story-swimlane').css('background-color', '#B8B8B8');
$('.story.closed').closest('.story-swimlane').appendTo('#tasks > tbody');
// Hard refresh board every 5 minutes
setInterval(function() {
var d = new Date();
var in_standup = false;
if(d.getHours() === 9){
if( (d.getMinutes() > 0) && (d.getMinutes() < 15) || (d.getMinutes() > 30) && (d.getMinutes() < 45) ) {
in_standup = true;
}
}
if($('.ui-dialog').length){
if($('.ui-dialog').css('display') == 'block'){
reload = false;
} else {
reload = true;
}
}
if( reload && ! in_standup ){
window.location.reload();
}
}, 300000);
$('.story_points').hover(function(i,el){
$(this).css({'backgroundColor': 'green', cursor: 'pointer'});
$(this).click(function(e){
var tr = $(this).parents('tr').first();
var u = window.location.protocol+'//'+window.location.host + '/issues/'+tr.attr('id').split('-')[1]+'.json';
var _request = {url: u, type: 'PUT', data: 'issue[status_id]=3'};
$.ajax(_request)
.always(function(data){
tr.css('background-color','#B8B8B8');
tr.appendTo('#tasks > tbody');
})
})
},
function(i,el){
$(this).css({'backgroundColor': 'rgb(255,136,0)', cursor: 'normal'});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment