Skip to content

Instantly share code, notes, and snippets.

@iaindooley iaindooley/toc_list
Last active Feb 25, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.