diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-02-27 21:03:54 +0200 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2019-02-27 21:03:54 +0200 |
commit | 82a728df7111413e4a1b106f4cd18265da5f397b (patch) | |
tree | 103291d880fcd494c115b216616a4e90bbff0832 /client/components/cards/cardDetails.js | |
parent | 3f067c793cba98df663fb7646d5d3aafc79efe09 (diff) | |
parent | 904b5bf0f5f6e36131bf2d081a5d08fef408ac81 (diff) | |
download | wekan-82a728df7111413e4a1b106f4cd18265da5f397b.tar.gz wekan-82a728df7111413e4a1b106f4cd18265da5f397b.tar.bz2 wekan-82a728df7111413e4a1b106f4cd18265da5f397b.zip |
Merge branch 'edge' into meteor-1.8
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r-- | client/components/cards/cardDetails.js | 58 |
1 files changed, 5 insertions, 53 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index a571e21a..73a7a67d 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -456,26 +456,9 @@ BlazeComponent.extendComponent({ }, }).register('boardsAndLists'); - -function cloneCheckList(_id, checklist) { - 'use strict'; - const checklistId = checklist._id; - checklist.cardId = _id; - checklist._id = null; - const newChecklistId = Checklists.insert(checklist); - ChecklistItems.find({checklistId}).forEach(function(item) { - item._id = null; - item.checklistId = newChecklistId; - item.cardId = _id; - ChecklistItems.insert(item); - }); -} - Template.copyCardPopup.events({ 'click .js-done'() { const card = Cards.findOne(Session.get('currentCard')); - const oldId = card._id; - card._id = null; const lSelect = $('.js-select-lists')[0]; card.listId = lSelect.options[lSelect.selectedIndex].value; const slSelect = $('.js-select-swimlanes')[0]; @@ -490,38 +473,13 @@ Template.copyCardPopup.events({ if (title) { card.title = title; card.coverId = ''; - const _id = Cards.insert(card); + const _id = card.copy(); // In case the filter is active we need to add the newly inserted card in // the list of exceptions -- cards that are not filtered. Otherwise the // card will disappear instantly. // See https://github.com/wekan/wekan/issues/80 Filter.addException(_id); - // copy checklists - let cursor = Checklists.find({cardId: oldId}); - cursor.forEach(function() { - cloneCheckList(_id, arguments[0]); - }); - - // copy subtasks - cursor = Cards.find({parentId: oldId}); - cursor.forEach(function() { - 'use strict'; - const subtask = arguments[0]; - subtask.parentId = _id; - subtask._id = null; - /* const newSubtaskId = */ Cards.insert(subtask); - }); - - // copy card comments - cursor = CardComments.find({cardId: oldId}); - cursor.forEach(function () { - 'use strict'; - const comment = arguments[0]; - comment.cardId = _id; - comment._id = null; - CardComments.insert(comment); - }); Popup.close(); } }, @@ -558,9 +516,8 @@ Template.copyChecklistToManyCardsPopup.events({ Filter.addException(_id); // copy checklists - let cursor = Checklists.find({cardId: oldId}); - cursor.forEach(function() { - cloneCheckList(_id, arguments[0]); + Checklists.find({cardId: oldId}).forEach((ch) => { + ch.copy(_id); }); // copy subtasks @@ -574,13 +531,8 @@ Template.copyChecklistToManyCardsPopup.events({ }); // copy card comments - cursor = CardComments.find({cardId: oldId}); - cursor.forEach(function () { - 'use strict'; - const comment = arguments[0]; - comment.cardId = _id; - comment._id = null; - CardComments.insert(comment); + CardComments.find({cardId: oldId}).forEach((cmt) => { + cmt.copy(_id); }); } Popup.close(); |