Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/1aef7ebc05ab2701366d020dc490209a to your computer and use it in GitHub Desktop.
Save iaindooley/1aef7ebc05ab2701366d020dc490209a to your computer and use it in GitHub Desktop.
Total for field in list name
function updateListTotalForMovedCard(notification)
{
var notif = new Notification(notification);
var added = notif.addedCard();
if(parts = /(.+) \(([0-9]+)\)/.exec(notif.listAfter().name()))
{
notif.listAfter().setName(parts[1]+" ("+totalPointsForList(notif.listAfter())+")");
if(parts = /(.+) \(([0-9]+)\)/.exec(notif.listBefore().name()))
{
notif.listBefore().setName(parts[1]+" ("+totalPointsForList(notif.listBefore())+")");
}
}
}
function updateListTotalForChangedFieldValue(notification)
{
var changed = new Notification(notification).changedCustomFieldValue();
if(parts = /(.+) \(([0-9]+)\)/.exec(changed.card().currentList().name()))
{
changed.card().currentList().setName(parts[1]+" ("+totalPointsForList(changed.card().currentList())+")");
}
}
function totalPointsForList(list)
{
var ret = 0;
list.cards().each(function(card)
{
ret += parseInt(card.customFieldValue("My Count"));
});
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment