diff options
author | Nicu Tofan <nicu.tofan@gmail.com> | 2018-06-19 01:00:14 +0300 |
---|---|---|
committer | Nicu Tofan <nicu.tofan@gmail.com> | 2018-06-26 14:32:48 +0300 |
commit | fd465fbb60bd92c169991e050b094904c2eec95e (patch) | |
tree | ae9d1960b29a180fcd77395d9d723408fb7395fb | |
parent | 879a84184ff2f9b8719f5ac1e25d35e0fa5f52fb (diff) | |
download | wekan-fd465fbb60bd92c169991e050b094904c2eec95e.tar.gz wekan-fd465fbb60bd92c169991e050b094904c2eec95e.tar.bz2 wekan-fd465fbb60bd92c169991e050b094904c2eec95e.zip |
Helpers for dealing with trees of cards
-rw-r--r-- | models/cards.js | 19 | ||||
-rw-r--r-- | server/migrations.js | 1 |
2 files changed, 19 insertions, 1 deletions
diff --git a/models/cards.js b/models/cards.js index c5d7cdf9..1e001501 100644 --- a/models/cards.js +++ b/models/cards.js @@ -297,14 +297,33 @@ Cards.helpers({ } return true; }, + + parentCard() { + if (this.parentId === '') { + return null; + } + return Cards.findOne(this.parentId); + }, + + isTopLevel() { + return this.parentId === ''; + }, }); Cards.mutations({ + applyToKids(funct) { + Cards.find({ parentId: this._id }).forEach((card) => { + funct(card); + }); + }, + archive() { + this.applyToKids((card) => { return card.archive(); }); return {$set: {archived: true}}; }, restore() { + this.applyToKids((card) => { return card.restore(); }); return {$set: {archived: false}}; }, diff --git a/server/migrations.js b/server/migrations.js index a32c2f2d..cfc0d5ab 100644 --- a/server/migrations.js +++ b/server/migrations.js @@ -258,7 +258,6 @@ Migrations.add('add-assigner-field', () => { }, noValidateMulti); }); - Migrations.add('add-parent-field-to-cards', () => { Cards.update({ parentId: { |