Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Last active February 25, 2019 22:43
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/3b5098e08fa2d92cbee6a1e1541de61a to your computer and use it in GitHub Desktop.
Save iaindooley/3b5098e08fa2d92cbee6a1e1541de61a to your computer and use it in GitHub Desktop.
ToC Lists
function createNewListCard(notification)
{
var notif = new Notification(notification);
var new_list = notif.addedList();
if(new_list.name() == "ToC")
{
notif.board().lists().each(function(list)
{
if(list.name() != "ToC")
{
Card.create(new_list,list.name()).addChecklist("Contents",function(checklist)
{
list.cards().each(function(card)
{
checklist.addItem(card.link());
});
});
}
});
}
else
{
var list_card = Card.create(notif.board().list("ToC"),notif.addedList().name());
notif.addedList().cards().each(function(card)
{
list_card.addChecklist("Contents",function(list)
{
list.addItem(card.link());
});
});
}
}
function addCardToList(notification)
{
var card = new Notification(notification).addedCard();
if(card.currentList().name() == "ToC")
throw new InvalidActionException("Ignore this one");
Card.findOrCreate(card.board().list("ToC"),card.currentList().name()).addChecklist("Contents",function(list)
{
list.addItem(card.link());
});
}
function removeListCard(notification)
{
var notif = new Notification(notification);
notif.board().list("ToC").card(notif.archivedList().name()).archive();
}
function checkOffArchivedToCItem(notification)
{
var notif = new Notification(notification);
notif.board().list("ToC").card(notif.archivedCard().currentList().name()).checkItemByName(notif.card().link());
}
function archiveCheckedOffToCItem(notification)
{
var notif = new Notification(notification);
var item = notif.completedChecklistItem();
if(!notif.member().notTrellinator())
throw new InvalidActionException("Ignore Trellinator checking off items");
if(item.checklist().card().currentList().name() == "ToC")
new Card({link: item.name()}).archive();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment