2
0
Эх сурвалжийг харах

Merge pull request #3451 from jrsupplee/copy-custom-fields

Copy custom fields to new board
Lauri Ojansivu 4 жил өмнө
parent
commit
bafda03fd9
1 өөрчлөгдсөн 19 нэмэгдсэн , 0 устгасан
  1. 19 0
      models/boards.js

+ 19 - 0
models/boards.js

@@ -518,6 +518,25 @@ Boards.helpers({
       swimlane.type = 'swimlane';
       swimlane.copy(_id);
     });
+
+    // copy custom field definitions
+    const cfMap = {};
+    CustomFields.find({ boardIds: oldId }).forEach(cf => {
+      const id = cf._id;
+      delete cf._id;
+      cf.boardIds = [_id];
+      cfMap[id] = CustomFields.insert(cf);
+    });
+    Cards.find({ boardId: _id }).forEach(card => {
+      Cards.update(card._id, {
+        $set: {
+          customFields: card.customFields.map(cf => {
+            cf._id = cfMap[cf._id];
+            return cf;
+          }),
+        },
+      });
+    });
   },
   /**
    * Is supplied user authorized to view this board?