浏览代码

Copy Checklist only copied the checklist items at the first time, now always

Martin Filser 2 年之前
父节点
当前提交
13fecfae27
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      models/checklists.js

+ 5 - 5
models/checklists.js

@@ -66,11 +66,11 @@ Checklists.attachSchema(
 
 
 Checklists.helpers({
 Checklists.helpers({
   copy(newCardId) {
   copy(newCardId) {
-    const oldChecklistId = this._id;
-    this._id = null;
-    this.cardId = newCardId;
-    const newChecklistId = Checklists.insert(this);
-    ChecklistItems.find({ checklistId: oldChecklistId }).forEach(function(
+    let copyObj = Object.assign({}, this);
+    delete copyObj._id;
+    copyObj.cardId = newCardId;
+    const newChecklistId = Checklists.insert(copyObj);
+    ChecklistItems.find({ checklistId: this._id }).forEach(function(
       item,
       item,
     ) {
     ) {
       item._id = null;
       item._id = null;