Last active
November 9, 2018 01:19
-
-
Save iaindooley/a64e2b529560202e99d33e337a9a10f4 to your computer and use it in GitHub Desktop.
Move completed checklists to a card
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 moveCompletedChecklistsToLinkedCard(notification) | |
{ | |
var notif = new Notification(notification); | |
if(!notif.member().notTrellinator()) | |
throw InvalidActionException("Only take this action for user completed checklists"); | |
var completed = notif.completedChecklist(); | |
try | |
{ | |
var linked = completed.card().cardsLinkedInAttachments().first(); | |
} | |
catch(e) | |
{ | |
Notification.expectException(InvalidDataException,e); | |
var linked = Card.create(completed.card().currentList(),"Completed Checklists from "+completed.card().id()).archive(); | |
completed.card().attachLink(linked.link()); | |
} | |
linked.addChecklist(completed.name()+" completed "+Trellinator.now().toLocaleString()+" by "+notif.member().name(),function(new_list) | |
{ | |
completed.items().each(function(item) | |
{ | |
new_list.addItem(item.name()); | |
}); | |
new_list.markAllItemsComplete(); | |
} | |
); | |
completed.remove(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment