mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Helpers for dealing with trees of cards
This commit is contained in:
parent
879a84184f
commit
fd465fbb60
2 changed files with 19 additions and 1 deletions
|
|
@ -297,14 +297,33 @@ Cards.helpers({
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
parentCard() {
|
||||||
|
if (this.parentId === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Cards.findOne(this.parentId);
|
||||||
|
},
|
||||||
|
|
||||||
|
isTopLevel() {
|
||||||
|
return this.parentId === '';
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Cards.mutations({
|
Cards.mutations({
|
||||||
|
applyToKids(funct) {
|
||||||
|
Cards.find({ parentId: this._id }).forEach((card) => {
|
||||||
|
funct(card);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
archive() {
|
archive() {
|
||||||
|
this.applyToKids((card) => { return card.archive(); });
|
||||||
return {$set: {archived: true}};
|
return {$set: {archived: true}};
|
||||||
},
|
},
|
||||||
|
|
||||||
restore() {
|
restore() {
|
||||||
|
this.applyToKids((card) => { return card.restore(); });
|
||||||
return {$set: {archived: false}};
|
return {$set: {archived: false}};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,6 @@ Migrations.add('add-assigner-field', () => {
|
||||||
}, noValidateMulti);
|
}, noValidateMulti);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Migrations.add('add-parent-field-to-cards', () => {
|
Migrations.add('add-parent-field-to-cards', () => {
|
||||||
Cards.update({
|
Cards.update({
|
||||||
parentId: {
|
parentId: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue