diff options
author | lksime <lkisme@me.com> | 2017-01-20 21:05:48 +0800 |
---|---|---|
committer | lksime <lkisme@me.com> | 2017-01-20 21:05:48 +0800 |
commit | 59731af139b73f4b9cd8bd0bd0602ac272538b4f (patch) | |
tree | 48711ded51c6540e6c01f439e566d22d6a6ac7a6 /models/cards.js | |
parent | 38c143b8bf569d6a08caf580b20d2fa5a4ea8abf (diff) | |
download | wekan-59731af139b73f4b9cd8bd0bd0602ac272538b4f.tar.gz wekan-59731af139b73f4b9cd8bd0bd0602ac272538b4f.tar.bz2 wekan-59731af139b73f4b9cd8bd0bd0602ac272538b4f.zip |
Add checklist feature
Diffstat (limited to 'models/cards.js')
-rw-r--r-- | models/cards.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/models/cards.js b/models/cards.js index 9e7d58c8..f6bd0b06 100644 --- a/models/cards.js +++ b/models/cards.js @@ -141,6 +141,36 @@ Cards.helpers({ return cover && cover.url() && cover; }, + checklists() { + return Checklists.find({ cardId: this._id }, { sort: { createdAt: 1 }}); + }, + + checklistItemCount() { + const checklists = this.checklists().fetch(); + return checklists.map((checklist) => { + return checklist.itemCount(); + }).reduce((prev, next) => { + return prev + next; + }, 0); + }, + + checklistFinishedCount() { + const checklists = this.checklists().fetch(); + return checklists.map((checklist) => { + return checklist.finishedCount(); + }).reduce((prev, next) => { + return prev + next; + }, 0); + }, + + checklistFinished() { + return this.hasChecklist() && this.checklistItemCount() === this.checklistFinishedCount(); + }, + + hasChecklist() { + return this.checklistItemCount() !== 0; + }, + absoluteUrl() { const board = this.board(); return FlowRouter.url('card', { |