diff options
author | Marc Hartmayer <hello@hartmayer.com> | 2020-04-29 22:38:50 +0200 |
---|---|---|
committer | Marc Hartmayer <hello@hartmayer.com> | 2020-04-30 01:59:04 +0200 |
commit | 2691f033cbd072864cf79e95d131a93449d3c84d (patch) | |
tree | 0e60c2677518b04e8b744b72b2cfd44bb18f92b7 /models | |
parent | c7d4a90d5cacb8dab205f122a6e2d9bca88e767b (diff) | |
download | wekan-2691f033cbd072864cf79e95d131a93449d3c84d.tar.gz wekan-2691f033cbd072864cf79e95d131a93449d3c84d.tar.bz2 wekan-2691f033cbd072864cf79e95d131a93449d3c84d.zip |
Fix creation of card links
Without this fix, orphaned card links are created and therefore this leads to
problems as described in https://github.com/wekan/wekan/issues/2785.
Diffstat (limited to 'models')
-rw-r--r-- | models/cards.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/cards.js b/models/cards.js index 4197f7ab..498140b9 100644 --- a/models/cards.js +++ b/models/cards.js @@ -428,6 +428,21 @@ Cards.helpers({ return _id; }, + link(boardId, swimlaneId, listId) { + // TODO is there a better method to create a deepcopy? + linkCard = JSON.parse(JSON.stringify(this)); + // TODO is this how it is meant to be? + linkCard.linkedId = linkCard.linkedId || linkCard._id; + linkCard.boardId = boardId; + linkCard.swimlaneId = swimlaneId; + linkCard.listId = listId; + linkCard.type = 'cardType-linkedCard'; + delete linkCard._id; + // TODO shall we copy the labels for a linked card?! + delete linkCard.labelIds; + return Cards.insert(linkCard); + }, + list() { return Lists.findOne(this.listId); }, |