Class: Checklist

TrelloEntities.Checklist(data)

The Checklist class represents a Checklist in Trello. You will typically interact with the Checklist object as the return value of methods on the Card object.

Constructor

new Checklist(data)

Parameters:
Name Type Description
data

(Object} key/value pairs of information, must at least contain "id", can basically just pass in response from Trello API

Source:
Examples
card.checklist("Something").items().each(function(item)
{
    card.postComment(item.name()+" is "+item.state());
});
card.addChecklist("New List",function(cl)
{
    cl.addItem("New Item");
});

Methods

(static) this.addItem(name, position)

Add an item to this checklist, even if it already exists

Parameters:
Name Type Description
name string

the name for the checklist item

position int

(optional) where to add the item

Source:
Example
card.addChecklist("Some List",function(list)
{
    list.addItem(card.link());
});

(static) this.addUniqueItem(name, position)

Add an item to this checklist if an item with the same name does not already exist

Parameters:
Name Type Description
name string

the name for the checklist item

position int

(optional) where to add the item

Source:
Example
card.addChecklist("Some List",function(list)
{
    list.addUniqueItem(card.link());
});

(static) this.card()

Return the card that this checklist is on

Source:
Example
new Notification(posted).completedChecklist().card().postComment("Well done!");

(static) this.convertIntoLinkedCards(list, params)

Convert this checklist into a list of links to newly created cards in the given list, with each card being named after the original checklist item and each checklist item being linked to the newly created card. Each newly created card has a link to the source card in the description.

Parameters:
Name Type Description
list List

the list in which to create the new cards

params Object

(optional) an optional set of key/value pairs in an Object to use when creating the cards, the list of allowed attributes is at https://developers.trello.com/reference/#cards-2

Source:
Example
//Convert into linked cards with each card having 
//the same labels and members as the original card
var member_ids = card.members().find(function(member)
{
    return member.id();
}).implodeValues(",");
var label_ids = card.labels().find(function(label)
{
    return label.id();
}).implodeValues(",");
card.checklist("Something")
.convertIntoLinkedCards(card.board().findOrCreateList(card.name()+" Linked Cards"),
                        {idLabels: label_ids,
                         idMembers: member_ids});

(static) this.deleteItems(state)

Delete all items matching the given state

Parameters:
Name Type Description
state string

either complete or incomplete

Source:
Example
card.checklist("Something").deleteItems("complete");

(static) this.id()

Return the id of this checklist

Source:
Example
card.checklist("Something").id();

(static) this.isComplete()

Return true if all items in this checklist are complete

Source:
Example
if(card.checklist("Something").isComplete())
    card.postComment("Something is complete");

(static) this.item(name)

Return an item from this checklist by name or RegExp

Parameters:
Name Type Description
name string | RegExp

the name or regex to match against the item name

Source:
Example
card.checklist("Something").item(new RegExp("Iain's.*")).markComplete();

(static) this.items(name)

Return an IterableCollection of checklist items optionally filered by name or RegExp

Parameters:
Name Type Description
name string | RegExp

filter the list by string or RegExp

Source:
Example
card.checklist("Something").items(new RegExp("Iain's.*")).each(function(item)
{
    item.remove();
});

(static) this.markAllItemsComplete()

Mark all items complete

Source:
Example
card.checklist("Something").markAllItemsComplete();

(static) this.name()

Return the name of this checklist

Source:
Example
card.postComment(new Notification(posted).completedChecklist().name()+" was completed");

(static) this.remove()

Remove this checklist from the containing card

Source:
Example
card.checklist("Something").remove();

(static) this.reset()

Mark all items incomplete

Source:
Example
card.checklist("Something").reset();

(static) this.setName(name)

Set the name of this checklist

Parameters:
Name Type Description
name string

the new name for the checklist

Source:
Example
card.checklist("Old Name").setName("New Name");

(static) this.setPosition(position)

Set the position of this checklist

Parameters:
Name Type Description
position string | number

either top, bottom or a positive number

Source:
Example
card.checklist("My Checklist").setPosition("top");