Prepare to create card from template

This commit is contained in:
Andrés Manelli 2019-02-23 16:36:29 +01:00
parent 7a6afb8aea
commit 0fec711545
7 changed files with 57 additions and 60 deletions

View file

@ -272,6 +272,31 @@ Cards.allow({
});
Cards.helpers({
copy() {
const oldId = this._id;
this._id = null;
const _id = Cards.insert(this);
// copy checklists
Checklists.find({cardId: oldId}).forEach((ch) => {
ch.copy(_id);
});
// copy subtasks
Cards.find({parentId: oldId}).forEach((subtask) => {
subtask.parentId = _id;
subtask._id = null;
Cards.insert(subtask);
});
// copy card comments
CardComments.find({cardId: oldId}).forEach((cmt) => {
cmt.copy(_id);
});
return _id;
},
list() {
return Lists.findOne(this.listId);
},