소스 검색

Merge pull request #4981 from mfilser/copy_checklist_only_copied_the_checklist_items_the_first_time

Copy Checklist only copied the checklist items at the first time, now always
Lauri Ojansivu 2 년 전
부모
커밋
7862e280ec
1개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 5
      models/checklists.js

+ 5 - 5
models/checklists.js

@@ -66,11 +66,11 @@ Checklists.attachSchema(
 
 Checklists.helpers({
   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._id = null;