summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
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}};
},