Merge branch 'Tentoe-boardimportbug' into devel

Fixed Members do not get included on board import from Wekan.
Thanks to Tentoe ! Closes #1255
This commit is contained in:
Lauri Ojansivu 2017-10-31 06:48:40 +02:00
commit d3d73e9cdd
2 changed files with 25 additions and 29 deletions

View file

@ -5,7 +5,11 @@ This release adds the following new features:
* [Permit editing WIP limit](https://github.com/wekan/wekan/pull/1312); * [Permit editing WIP limit](https://github.com/wekan/wekan/pull/1312);
* [Image attachment resize on smaller screens and swipebox](https://github.com/wekan/wekan/pull/1315). * [Image attachment resize on smaller screens and swipebox](https://github.com/wekan/wekan/pull/1315).
Thanks to GitHub users brooksbecton, nztqa and ocdtrekkie for their contributions. and fixes the following bugs:
* [Members do not get included on board import from Wekan](https://github.com/wekan/wekan/pull/1316).
Thanks to GitHub users brooksbecton, nztqa, ocdtrekkie and Tentoe for their contributions.
# v0.51 2017-10-25 Wekan release # v0.51 2017-10-25 Wekan release

View file

@ -133,47 +133,39 @@ export class WekanCreator {
} }
// You must call parseActions before calling this one. // You must call parseActions before calling this one.
createBoardAndLabels(wekanBoard) { createBoardAndLabels(boardToImport) {
const boardToCreate = { const boardToCreate = {
archived: wekanBoard.archived, archived: boardToImport.archived,
color: wekanBoard.color, color: boardToImport.color,
// very old boards won't have a creation activity so no creation date // very old boards won't have a creation activity so no creation date
createdAt: this._now(wekanBoard.createdAt), createdAt: this._now(boardToImport.createdAt),
labels: [], labels: [],
members: [{ members: [{
userId: Meteor.userId(), userId: Meteor.userId(),
isAdmin: true, wekanId: Meteor.userId(),
isActive: true, isActive: true,
isAdmin: true,
isCommentOnly: false, isCommentOnly: false,
}], }],
// Standalone Export has modifiedAt missing, adding modifiedAt to fix it // Standalone Export has modifiedAt missing, adding modifiedAt to fix it
modifiedAt: this._now(wekanBoard.modifiedAt), modifiedAt: this._now(boardToImport.modifiedAt),
permission: wekanBoard.permission, permission: boardToImport.permission,
slug: getSlug(wekanBoard.title) || 'board', slug: getSlug(boardToImport.title) || 'board',
stars: 0, stars: 0,
title: wekanBoard.title, title: boardToImport.title,
}; };
// now add other members // now add other members
if(wekanBoard.members) { if(boardToImport.members) {
wekanBoard.members.forEach((wekanMember) => { boardToImport.members.forEach((wekanMember) => {
const wekanId = wekanMember.userId; // do we already have it in our list?
// do we have a mapping? if(!boardToCreate.members.some((member) => member.wekanId === wekanMember.wekanId))
if(this.members[wekanId]) { boardToCreate.members.push({
const wekanId = this.members[wekanId]; ... wekanMember,
// do we already have it in our list? userId: wekanMember.wekanId,
const wekanMember = boardToCreate.members.find((wekanMember) => wekanMember.userId === wekanId); });
if(!wekanMember) {
boardToCreate.members.push({
userId: wekanId,
isAdmin: wekanMember.isAdmin,
isActive: true,
isCommentOnly: false,
});
}
}
}); });
} }
wekanBoard.labels.forEach((label) => { boardToImport.labels.forEach((label) => {
const labelToCreate = { const labelToCreate = {
_id: Random.id(6), _id: Random.id(6),
color: label.color, color: label.color,
@ -192,7 +184,7 @@ export class WekanCreator {
boardId, boardId,
createdAt: this._now(), createdAt: this._now(),
source: { source: {
id: wekanBoard.id, id: boardToImport.id,
system: 'Wekan', system: 'Wekan',
}, },
// We attribute the import to current user, // We attribute the import to current user,