Created
June 17, 2014 13:47
-
-
Save paddelkraft/82362a55b2c2c2b05150 to your computer and use it in GitHub Desktop.
Tfs 2012 Kanban board inprovements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Kanban improve (common) | |
// @namespace http://tfs2012.company.net/ | |
// @version 0.1 | |
// @description Does the usability improvements over standard SharePoint Kanban board | |
// @match http://tfs2012.company.net:8080/tfs/Global/Shop/_backlogs/board | |
// @copyright 2014+ | |
// ==/UserScript==a | |
(function () { | |
var is_focused = true; | |
var customStyle = | |
".board-tile.pale {background-color: transparent; border-color: #ddd; color: #ddd}" + | |
".board-tile.at.pale {background-color: transparent; border-color: #ddd; color: #ddd}" + | |
".board-tile.cr.pale {background-color: transparent; border-color: #ddd; color: #ddd}" + | |
".board-tile.expediter.pale {background-color: transparent; border-color: #ddd; color: #ddd}" + | |
".board-tile.blocked.pale {background-color: transparent; border-color: #ddd; color: #ddd}" | |
; | |
function improveBoard() { | |
if (!is_focused || ($(".board-tile").length < 1)) { | |
setTimeout(improveBoard, 1000); | |
return; | |
} | |
var allIds = []; | |
$(".board-tile") | |
.each(function () { | |
var itemElm = $(this); | |
allIds.push(itemElm.attr('data-item-id')); | |
}); | |
console.log("Kanban improve: item ids: " + allIds); | |
var oDataValidationToken = $('[name=__RequestVerificationToken]').val(); | |
$.post( | |
"//" + window.location.host + "/tfs/Global/_api/_wit/pageWorkItems", | |
{ | |
workItemIds: "" + allIds, | |
fields: "System.Id,System.State,System.TeamProject,System.Title,System.WorkItemType,company.ecomTeam,Microsoft.VSTS.CMMI.Blocked,company.Common.CaseOrigin,company.Common.CaseOriginNumber", | |
__RequestVerificationToken: oDataValidationToken | |
}, | |
function (data) { | |
$.each(data.rows, function (_, item) { | |
var itemId = item[0]; | |
var itemIsBlocked = item[6] || "No"; | |
var itemClassification = item[5] || ""; | |
var caseId = (item[7] || "") + "|" + (item[8] || ""); | |
var $itemElm = $(".board-tile[data-item-id=" + itemId + "]"); | |
$itemElm.attr('data-case-id', caseId); | |
setClassBasedOnExpectation($itemElm, | |
['CRExpedited', 'ATExpedited'], itemClassification, | |
'expediter'); | |
setClassBasedOnExpectation($itemElm, | |
"Yes", itemIsBlocked, | |
'blocked'); | |
setClassBasedOnExpectation($itemElm, | |
'CR', itemClassification, | |
'cr'); | |
setClassBasedOnExpectation($itemElm, | |
'AT', itemClassification, | |
'at'); | |
}); | |
}); | |
setTimeout(improveBoard, 5000); | |
} | |
function setClassBasedOnExpectation($elm, expected, actual, className) { | |
var evaluationResult = false; | |
if ($.isArray(expected)) { | |
$.each(expected, function (_, elm) { | |
evaluationResult |= elm == actual; | |
}); | |
} else { | |
evaluationResult = expected == actual; | |
} | |
if (evaluationResult) { | |
$elm.addClass(className); | |
} else { | |
$elm.removeClass(className); | |
} | |
} | |
function setCaseHighLight() { | |
if ($("[data-case-id]").length < 1) { | |
setTimeout(setCaseHighLight, 1000); | |
return; | |
} | |
$('[data-case-id]') | |
.mouseenter(function (evt) { | |
var caseId = $(evt.target).attr('data-case-id') || $(evt.target).closest('[data-case-id]').attr('data-case-id'); | |
console.log('Mouse enter... case #:' + caseId) | |
$("[data-case-id!='" + caseId + "']").addClass('pale') | |
}) | |
.mouseleave(function (evt) { | |
$("[data-case-id]").removeClass('pale') | |
}); | |
} | |
function addGlobalStyle(css) { | |
var head, style; | |
head = document.getElementsByTagName('head')[0]; | |
if (!head) { return; } | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
head.appendChild(style); | |
} | |
$(function () { | |
improveBoard(); | |
setCaseHighLight(); | |
addGlobalStyle(customStyle); | |
$(window) | |
.focus(function () { is_focused = true; }) | |
.blur(function () { is_focused = false; }); | |
}); | |
})(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Kanban improve (Business-specific) | |
// @namespace http://tfs2012.company.net/b | |
// @version 0.1 | |
// @description Does the usability omprovements over standard SharePoint Kanban board | |
// @match http://tfs2012.company.net:8080/tfs/Global/Shop/_backlogs/board | |
// @copyright 2014+ | |
// ==/UserScript==a | |
(function () { | |
var customStyle = | |
".board-tile.cr {background-color: #3276b1; border-color: #285e8e; color: white} " + | |
".board-tile.at {color: gray} " + | |
".board-tile.expediter {background-color: #ed9c28; border-color: #d58512; color: white} " + | |
".board-tile.blocked {background-color: #d2322d; border-color: #ac2925; color: white} " | |
; | |
function addGlobalStyle(css) { | |
var head, style; | |
head = document.getElementsByTagName('head')[0]; | |
if (!head) { return; } | |
style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = css; | |
head.appendChild(style); | |
} | |
$(function () { | |
addGlobalStyle(customStyle); | |
}); | |
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ecom Direct Board links | |
// @namespace http://tfs2012.company.net/t | |
// @version 0.1 | |
// @description Adds links To Business Board and team board | |
// @match http://tfs2012.company.net:8080/tfs/Global/Shop/* | |
// @copyright 2014+, | |
// ==/UserScript== | |
addHubGroupLink("Business Board", "http://link"); | |
addHubGroupLink("Team Board", "http://link"); | |
addHubGroupLink("Definition Of Done", "http://link" ); | |
addHubGroupLink("Process Information","http://link"); | |
addHubGroupLink("http://link"); | |
//addHubGroupLink("caption", "url"); | |
function addHubGroupLink(caption, url){ | |
var link = document.createElement('li'); | |
link.innerHTML = "<a href='"+ url +"' >" + caption + " </a>"; | |
appendLiToUlByClass("hub-groups", link); | |
} | |
function appendLiToUlByClass(matchClass, li) { | |
var elems = document.getElementsByTagName('ul'), i; | |
for (i in elems) { | |
if((' ' + elems[i].className + ' ').indexOf(' ' + matchClass + ' ') > -1) { | |
elems[i].appendChild(li); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While this code is working i have created a full fledged Chrome extension out of this and much more so if you are interested in this gist i sugest you take a look at that instead.
it is Called TFS Kanban buddy and can be found in chrome store or as Code here at Github
https://chrome.google.com/webstore/detail/tfs-kanban-buddy/bnkanimchogkpkjbabhoficohanbhalp