diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-02-03 02:02:47 +0200 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-02-03 02:02:47 +0200 |
commit | 40594485d869be1638ea619bf655cc1de2e079db (patch) | |
tree | 70bb050626b491155f393db2ff3f5546d6a6ae2c /models/cards.js | |
parent | 70f92c6e0e3e15444cdb20987ce0544ec691d606 (diff) | |
parent | 335b91f0a48c2c64a96a74e8a2b9866bf590714a (diff) | |
download | wekan-40594485d869be1638ea619bf655cc1de2e079db.tar.gz wekan-40594485d869be1638ea619bf655cc1de2e079db.tar.bz2 wekan-40594485d869be1638ea619bf655cc1de2e079db.zip |
Add checklist feature: Merge branch 'lkisme-ckls' into devel
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', { |