summaryrefslogtreecommitdiffstats
path: root/models/cards.js
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2019-02-23 16:36:29 +0100
committerAndrés Manelli <andresmanelli@gmail.com>2019-02-24 00:05:00 +0100
commit0fec7115451ba3b49442965c8160df4911157601 (patch)
tree12364d6c96f0900aea318b16863a246b6c6dd9ee /models/cards.js
parent7a6afb8aea2c3398ec0fe34d664398bd94cac90a (diff)
downloadwekan-0fec7115451ba3b49442965c8160df4911157601.tar.gz
wekan-0fec7115451ba3b49442965c8160df4911157601.tar.bz2
wekan-0fec7115451ba3b49442965c8160df4911157601.zip
Prepare to create card from template
Diffstat (limited to 'models/cards.js')
-rw-r--r--models/cards.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/models/cards.js b/models/cards.js
index e9fc453e..c7b4a366 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -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);
},