Created
May 20, 2020 05:47
-
-
Save iaindooley/1aef7ebc05ab2701366d020dc490209a to your computer and use it in GitHub Desktop.
Total for field in list name
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
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