Created
June 17, 2013 13:32
-
-
Save JonnyFunFun/5796885 to your computer and use it in GitHub Desktop.
Kanban Column Hider mashup with per-project configuration logic
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
tau.mashups | |
.addDependency('libs/jquery/jquery') | |
.addMashup(function ($, config) { | |
// Put projects => states' names that you want to hide here | |
// projects can be a regular expression | |
var statesToHideConfiguration = { | |
'Private Universe #[0-9]+': ['Invalid', 'Fixed'] | |
}; | |
// gathers the project name from the div.x-panel-kanban-header > span | |
var getProjectName = function(b) { | |
return $(b).parents('div.x-panel:last').find('div.x-panel-kanban-header:first').find('span:last').html(); | |
}; | |
// returns the column configuration by project name | |
var getColumnConfig = function(p) { | |
var ret = null; | |
$.each(statesToHideConfiguration, function(project, config) { | |
if (new RegExp(project).test(p)) { | |
ret = config; | |
return false; | |
} | |
}); | |
return ret; | |
}; | |
// loop through our tables and do the hiding | |
$(document).ready(function() { | |
$('table.kanban-swimlanes-table').each(function() { | |
var tableHead = $(this).find('thead:first'); | |
// gather the configuration for this project | |
var statesToHide = getColumnConfig(getProjectName(this)); | |
// if we have a config, do the hiding | |
if ((statesToHide != null) && (tableHead != null)) { | |
for (var i = 0; i < statesToHide.length; i++) { | |
var header = $(".kanban-swimlane-header-wrap span:contains('"+statesToHide[i]+"')").filter(function() { | |
return $(this).text().match("^"+statesToHide[i]) != null; | |
}).parent(); | |
//use header Id to construct column Id | |
var col = $("#" + header.id().replace("header-", "")); | |
//hide everything | |
header.hide(); | |
col.hide(); | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment