Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change project list page(Redmine view customize plugin)
// Path pattern: /projects/?$
// Type : JavaScript
$(function() {
var root = $('#projects-index').children('.projects').children('li');
var rows = [];
for (var i = 0, len = root.length; i < len; i++) {
var target = root.eq(i);
rows.push(createRow(target));
Array.prototype.push.apply(
rows, createSubtreeRows(target, 1));
}
var table = $('<table class="list"><th width="30%">プロジェクト</th><th>概要</th></table>');
for (var i = 0; i < rows.length; i++) {
table.append(rows[i].addClass((i % 2 == 0) ? 'odd' : 'even'));
}
$('#projects-index').append(table);
/////////////////////////////////////////////////////////
function createSubtreeRows(parent, level) {
var rows = [];
var sub = parent.children('.projects').children('li.child');
for (var i = 0, len = sub.length; i < len; i++) {
var target = sub.eq(i);
rows.push(
createRow(target, parent, level));
Array.prototype.push.apply(
rows, createSubtreeRows(target, level + 1));
}
return rows;
}
function createRow(target, parent, level) {
var link = target.children('div').children('a');
var description = target.children('div').children('div');
var tr = $('<tr>')
tr.addClass('project');
if (parent) {
tr.addClass('child').addClass('leaf');
} else {
tr.addClass('parent').addClass('root');
}
if (level > 0) {
tr.addClass('idnt').addClass('idnt-' + level);
}
tr.append($('<td>').append($('<span>').append(link)).addClass('name'));
tr.append($('<td>').append(description).addClass('description'));
return tr;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.