diff options
Diffstat (limited to 'models/boards.js')
-rw-r--r-- | models/boards.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index 0d3213bc..0db2e48e 100644 --- a/models/boards.js +++ b/models/boards.js @@ -315,6 +315,21 @@ Boards.attachSchema(new SimpleSchema({ Boards.helpers({ + copy() { + const oldId = this._id; + delete this._id; + const _id = Boards.insert(this); + + // Copy all swimlanes in board + Swimlanes.find({ + boardId: oldId, + archived: false, + }).forEach((swimlane) => { + swimlane.type = 'swimlane'; + swimlane.boardId = _id; + swimlane.copy(oldId); + }); + }, /** * Is supplied user authorized to view this board? */ @@ -463,6 +478,27 @@ Boards.helpers({ return _id; }, + searchBoards(term) { + check(term, Match.OneOf(String, null, undefined)); + + const query = { boardId: this._id }; + query.type = 'cardType-linkedBoard'; + query.archived = false; + + const projection = { limit: 10, sort: { createdAt: -1 } }; + + if (term) { + const regex = new RegExp(term, 'i'); + + query.$or = [ + { title: regex }, + { description: regex }, + ]; + } + + return Cards.find(query, projection); + }, + searchSwimlanes(term) { check(term, Match.OneOf(String, null, undefined)); |