summaryrefslogtreecommitdiffstats
path: root/models/swimlanes.js
diff options
context:
space:
mode:
authorAndrés Manelli <andresmanelli@gmail.com>2019-02-25 22:48:25 +0100
committerAndrés Manelli <andresmanelli@gmail.com>2019-02-25 22:48:32 +0100
commitdc7286a0ef8111c0855129911492588ba8a384df (patch)
treedcc4f9be071a1bf55d1f2638ed63c958e0a42634 /models/swimlanes.js
parent13c2157e36f65be4138a85fae0379e0fe31f02bd (diff)
downloadwekan-dc7286a0ef8111c0855129911492588ba8a384df.tar.gz
wekan-dc7286a0ef8111c0855129911492588ba8a384df.tar.bz2
wekan-dc7286a0ef8111c0855129911492588ba8a384df.zip
Fix list view issues. Allow creation of boards from templates
Diffstat (limited to 'models/swimlanes.js')
-rw-r--r--models/swimlanes.js19
1 files changed, 12 insertions, 7 deletions
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);
});