diff options
author | Keven Kurz PC <keven.kurz@gmail.com> | 2017-10-29 16:34:49 +0100 |
---|---|---|
committer | Keven Kurz PC <keven.kurz@gmail.com> | 2017-10-29 16:34:49 +0100 |
commit | e8cfed1f7b7ea159f606e096495406b738c70672 (patch) | |
tree | 0d1f38c7db03abe89e5e7ebe8f15bf14576f4dbf /models | |
parent | 01507576b1c3c3ad148969691d1e22bf7addbeb9 (diff) | |
download | wekan-e8cfed1f7b7ea159f606e096495406b738c70672.tar.gz wekan-e8cfed1f7b7ea159f606e096495406b738c70672.tar.bz2 wekan-e8cfed1f7b7ea159f606e096495406b738c70672.zip |
fixed Members do not get included on board import from WeKan #1255
fixed multiple errors where constants were mistakenly overridden.(or
trying to get a property of an object after making sure it doesn't
exits)
renamed wekanBoard Parameter from createBoardAndLabels for clairity
reworked adding admin for imorter
Diffstat (limited to 'models')
-rw-r--r-- | models/wekanCreator.js | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/models/wekanCreator.js b/models/wekanCreator.js index 3cd65fd7..c77143ca 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -133,47 +133,35 @@ export class WekanCreator { } // You must call parseActions before calling this one. - createBoardAndLabels(wekanBoard) { + createBoardAndLabels(boardToImport) { const boardToCreate = { - archived: wekanBoard.archived, - color: wekanBoard.color, + archived: boardToImport.archived, + color: boardToImport.color, // very old boards won't have a creation activity so no creation date - createdAt: this._now(wekanBoard.createdAt), + createdAt: this._now(boardToImport.createdAt), labels: [], - members: [{ - userId: Meteor.userId(), - isAdmin: true, - isActive: true, - isCommentOnly: false, - }], + members: [], // Standalone Export has modifiedAt missing, adding modifiedAt to fix it - modifiedAt: this._now(wekanBoard.modifiedAt), - permission: wekanBoard.permission, - slug: getSlug(wekanBoard.title) || 'board', + modifiedAt: this._now(boardToImport.modifiedAt), + permission: boardToImport.permission, + slug: getSlug(boardToImport.title) || 'board', stars: 0, - title: wekanBoard.title, + title: boardToImport.title, }; // now add other members - if(wekanBoard.members) { - wekanBoard.members.forEach((wekanMember) => { - const wekanId = wekanMember.userId; - // do we have a mapping? - if(this.members[wekanId]) { - const wekanId = this.members[wekanId]; - // do we already have it in our list? - const wekanMember = boardToCreate.members.find((wekanMember) => wekanMember.userId === wekanId); - if(!wekanMember) { - boardToCreate.members.push({ - userId: wekanId, - isAdmin: wekanMember.isAdmin, - isActive: true, - isCommentOnly: false, - }); - } - } + if(boardToImport.members) { + boardToImport.members.forEach((wekanMember) => { + // do we already have it in our list? + const foundWekanMember = boardToCreate.members.find((member) => member.wekanId === wekanMember.wekanId); + if(!foundWekanMember) + boardToCreate.members.push({ + ... wekanMember, + userId: wekanMember.wekanId, + ...Meteor.userId() === wekanMember.wekanId ? {isAdmin: true} : {}, // make impoter admin + }); }); } - wekanBoard.labels.forEach((label) => { + boardToImport.labels.forEach((label) => { const labelToCreate = { _id: Random.id(6), color: label.color, @@ -192,7 +180,7 @@ export class WekanCreator { boardId, createdAt: this._now(), source: { - id: wekanBoard.id, + id: boardToImport.id, system: 'Wekan', }, // We attribute the import to current user, |