diff options
author | Andrés Manelli <andresmanelli@gmail.com> | 2019-02-25 22:48:25 +0100 |
---|---|---|
committer | Andrés Manelli <andresmanelli@gmail.com> | 2019-02-25 22:48:32 +0100 |
commit | dc7286a0ef8111c0855129911492588ba8a384df (patch) | |
tree | dcc4f9be071a1bf55d1f2638ed63c958e0a42634 /models/boards.js | |
parent | 13c2157e36f65be4138a85fae0379e0fe31f02bd (diff) | |
download | wekan-dc7286a0ef8111c0855129911492588ba8a384df.tar.gz wekan-dc7286a0ef8111c0855129911492588ba8a384df.tar.bz2 wekan-dc7286a0ef8111c0855129911492588ba8a384df.zip |
Fix list view issues. Allow creation of boards from templates
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)); |