From f888cfd565b197903c24a07221f6a6a44e1b6223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Manelli?= Date: Sat, 23 Feb 2019 20:41:36 +0100 Subject: Allow list creation from template --- models/lists.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'models/lists.js') diff --git a/models/lists.js b/models/lists.js index 236432cc..e2ded36e 100644 --- a/models/lists.js +++ b/models/lists.js @@ -137,6 +137,24 @@ Lists.allow({ }); Lists.helpers({ + copy() { + const oldId = this._id; + this._id = null; + const _id = Lists.insert(this); + + // Copy all cards in list + Cards.find({ + listId: oldId, + archived: false, + }).forEach((card) => { + card.type = 'cardType-card'; + card.listId = _id; + card.boardId = this.boardId; + card.swimlaneId = this.swimlaneId; + card.copy(); + }); + }, + cards(swimlaneId) { const selector = { listId: this._id, -- cgit v1.2.3-1-g7c22