|
@@ -21,8 +21,7 @@ class TrelloCreator {
|
|
const createdAt = this.createdAt.board;
|
|
const createdAt = this.createdAt.board;
|
|
const boardToCreate = {
|
|
const boardToCreate = {
|
|
archived: trelloBoard.closed,
|
|
archived: trelloBoard.closed,
|
|
- // XXX map from Trello colors
|
|
|
|
- color: Boards.simpleSchema()._schema.color.allowedValues[0],
|
|
|
|
|
|
+ color: this.getColor(trelloBoard.prefs.background),
|
|
createdAt,
|
|
createdAt,
|
|
labels: [],
|
|
labels: [],
|
|
members: [{
|
|
members: [{
|
|
@@ -46,12 +45,14 @@ class TrelloCreator {
|
|
this.labels[label.id] = labelToCreate;
|
|
this.labels[label.id] = labelToCreate;
|
|
boardToCreate.labels.push(labelToCreate);
|
|
boardToCreate.labels.push(labelToCreate);
|
|
});
|
|
});
|
|
|
|
+ const now = new Date();
|
|
const boardId = Boards.direct.insert(boardToCreate);
|
|
const boardId = Boards.direct.insert(boardToCreate);
|
|
|
|
+ Boards.direct.update(boardId, {$set: {modifiedAt: now}});
|
|
// log activity
|
|
// log activity
|
|
Activities.direct.insert({
|
|
Activities.direct.insert({
|
|
activityType: 'importBoard',
|
|
activityType: 'importBoard',
|
|
boardId,
|
|
boardId,
|
|
- createdAt: new Date(),
|
|
|
|
|
|
+ createdAt: now,
|
|
source: {
|
|
source: {
|
|
id: trelloBoard.id,
|
|
id: trelloBoard.id,
|
|
system: 'Trello',
|
|
system: 'Trello',
|
|
@@ -72,14 +73,17 @@ class TrelloCreator {
|
|
title: list.name,
|
|
title: list.name,
|
|
userId: Meteor.userId(),
|
|
userId: Meteor.userId(),
|
|
};
|
|
};
|
|
- listToCreate._id = Lists.direct.insert(listToCreate);
|
|
|
|
|
|
+ const listId = Lists.direct.insert(listToCreate);
|
|
|
|
+ const now = new Date();
|
|
|
|
+ Lists.direct.update(listId, {$set: {'updatedAt': now}});
|
|
|
|
+ listToCreate._id = listId;
|
|
this.lists[list.id] = listToCreate;
|
|
this.lists[list.id] = listToCreate;
|
|
// log activity
|
|
// log activity
|
|
Activities.direct.insert({
|
|
Activities.direct.insert({
|
|
activityType: 'importList',
|
|
activityType: 'importList',
|
|
boardId,
|
|
boardId,
|
|
- createdAt: new Date(),
|
|
|
|
- listId: listToCreate._id,
|
|
|
|
|
|
+ createdAt: now,
|
|
|
|
+ listId,
|
|
source: {
|
|
source: {
|
|
id: list.id,
|
|
id: list.id,
|
|
system: 'Trello',
|
|
system: 'Trello',
|
|
@@ -139,6 +143,7 @@ class TrelloCreator {
|
|
// XXX use the original comment user instead
|
|
// XXX use the original comment user instead
|
|
userId: Meteor.userId(),
|
|
userId: Meteor.userId(),
|
|
};
|
|
};
|
|
|
|
+ // dateLastActivity will be set from activity insert, no need to update it ourselves
|
|
const commentId = CardComments.direct.insert(commentToCreate);
|
|
const commentId = CardComments.direct.insert(commentToCreate);
|
|
Activities.direct.insert({
|
|
Activities.direct.insert({
|
|
activityType: 'addComment',
|
|
activityType: 'addComment',
|
|
@@ -154,6 +159,23 @@ class TrelloCreator {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ getColor(trelloColorCode) {
|
|
|
|
+ // trello color name => wekan color
|
|
|
|
+ const mapColors = {
|
|
|
|
+ 'blue': 'belize',
|
|
|
|
+ 'orange': 'pumpkin',
|
|
|
|
+ 'green': 'nephritis',
|
|
|
|
+ 'red': 'pomegranate',
|
|
|
|
+ 'purple': 'wisteria',
|
|
|
|
+ 'pink': 'pomegranate',
|
|
|
|
+ 'lime': 'nephritis',
|
|
|
|
+ 'sky': 'belize',
|
|
|
|
+ 'grey': 'midnight',
|
|
|
|
+ };
|
|
|
|
+ const wekanColor = mapColors[trelloColorCode];
|
|
|
|
+ return wekanColor || Boards.simpleSchema()._schema.color.allowedValues[0];
|
|
|
|
+ }
|
|
|
|
+
|
|
parseActions(trelloActions) {
|
|
parseActions(trelloActions) {
|
|
trelloActions.forEach((action) => {
|
|
trelloActions.forEach((action) => {
|
|
switch (action.type) {
|
|
switch (action.type) {
|
|
@@ -202,7 +224,6 @@ Meteor.methods({
|
|
const boardId = trelloCreator.createBoardAndLabels(trelloBoard);
|
|
const boardId = trelloCreator.createBoardAndLabels(trelloBoard);
|
|
trelloCreator.createLists(trelloBoard.lists, boardId);
|
|
trelloCreator.createLists(trelloBoard.lists, boardId);
|
|
trelloCreator.createCardsAndComments(trelloBoard.cards, boardId);
|
|
trelloCreator.createCardsAndComments(trelloBoard.cards, boardId);
|
|
- // XXX set modifiedAt or lastActivity
|
|
|
|
// XXX add members
|
|
// XXX add members
|
|
return boardId;
|
|
return boardId;
|
|
},
|
|
},
|