summaryrefslogtreecommitdiffstats
path: root/models/checklists.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/checklists.js')
-rw-r--r--models/checklists.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/models/checklists.js b/models/checklists.js
index a372fafa..9e763f1a 100644
--- a/models/checklists.js
+++ b/models/checklists.js
@@ -48,6 +48,19 @@ Checklists.attachSchema(new SimpleSchema({
}));
Checklists.helpers({
+ copy(newCardId) {
+ const oldChecklistId = this._id;
+ this._id = null;
+ this.cardId = newCardId;
+ const newChecklistId = Checklists.insert(this);
+ ChecklistItems.find({checklistId: oldChecklistId}).forEach((item) => {
+ item._id = null;
+ item.checklistId = newChecklistId;
+ item.cardId = newCardId;
+ ChecklistItems.insert(item);
+ });
+ },
+
itemCount() {
return ChecklistItems.find({ checklistId: this._id }).count();
},