Last active
May 8, 2017 11:16
-
-
Save vglebov/c212e75f921b1c077f481172b8920b87 to your computer and use it in GitHub Desktop.
Trac total for custom fields time_planned time_spent
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
... | |
<py:match path="div[@class="query"]"> | |
<div py:attrs="select('@*')">${select('*|comment()|text()')}</div> | |
<script language="JavaScript"> | |
//<![CDATA[ | |
var columns = []; | |
function getTotal(row_class, self) { | |
var total = 0; | |
if ($(self).find('th'+row_class).length) { | |
columns[row_class] = $(self).find('th'+row_class).first(); | |
} | |
$(self).find(row_class).each(function() { | |
var time = $(this).text().trim().replace(new RegExp('[,]', 'g'),'.'); | |
if (time) { total += parseFloat(time); } | |
}); | |
if (!isNaN(total) && total > 0 ) { | |
$(columns[row_class]).html($(columns[row_class]).html() + ' (' + total + ')'); | |
} | |
} | |
$('.listing.tickets thead,tbody').each(function() { | |
getTotal('.time_planned', this); | |
getTotal('.time_spent', this); | |
}); | |
// ]]> | |
</script> | |
</py:match> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment