From dc7286a0ef8111c0855129911492588ba8a384df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Manelli?= Date: Mon, 25 Feb 2019 22:48:25 +0100 Subject: Fix list view issues. Allow creation of boards from templates --- models/swimlanes.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'models/swimlanes.js') diff --git a/models/swimlanes.js b/models/swimlanes.js index d3548329..a3427fc6 100644 --- a/models/swimlanes.js +++ b/models/swimlanes.js @@ -101,18 +101,23 @@ Swimlanes.allow({ }); Swimlanes.helpers({ - copy() { + copy(oldBoardId) { const oldId = this._id; - this._id = null; + delete this._id; const _id = Swimlanes.insert(this); - // Copy all lists in swimlane - Lists.find({ - swimlaneId: oldId, + const query = { + swimlaneId: {$in: [oldId, '']}, archived: false, - }).forEach((list) => { + }; + if (oldBoardId) { + query.boardId = oldBoardId; + } + + // Copy all lists in swimlane + Lists.find(query).forEach((list) => { list.type = 'list'; - list.swimlaneId = ''; + list.swimlaneId = oldId; list.boardId = this.boardId; list.copy(_id); }); -- cgit v1.2.3-1-g7c22