summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNicu Tofan <nicu.tofan@gmail.com>2018-06-19 01:00:14 +0300
committerNicu Tofan <nicu.tofan@gmail.com>2018-06-26 14:32:48 +0300
commitfd465fbb60bd92c169991e050b094904c2eec95e (patch)
treeae9d1960b29a180fcd77395d9d723408fb7395fb /models
parent879a84184ff2f9b8719f5ac1e25d35e0fa5f52fb (diff)
downloadwekan-fd465fbb60bd92c169991e050b094904c2eec95e.tar.gz
wekan-fd465fbb60bd92c169991e050b094904c2eec95e.tar.bz2
wekan-fd465fbb60bd92c169991e050b094904c2eec95e.zip
Helpers for dealing with trees of cards
Diffstat (limited to 'models')
-rw-r--r--models/cards.js19
1 files changed, 19 insertions, 0 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}};
},