summaryrefslogtreecommitdiffstats
path: root/models/import.js
diff options
context:
space:
mode:
authorXavier Priour <xavier.priour@bubblyware.com>2015-10-19 11:46:04 +0200
committerXavier Priour <xavier.priour@bubblyware.com>2015-10-19 11:46:04 +0200
commit456674f1114f6e698891ad3b5b8b4bd505a550c5 (patch)
treee552a8c84335537846900a959e8e1ea3eef4b4d0 /models/import.js
parent4540bd36c4b07080ea5d29f0fb31bb20e637c2d5 (diff)
downloadwekan-456674f1114f6e698891ad3b5b8b4bd505a550c5.tar.gz
wekan-456674f1114f6e698891ad3b5b8b4bd505a550c5.tar.bz2
wekan-456674f1114f6e698891ad3b5b8b4bd505a550c5.zip
Import board: set proper color and modifiedAt dates
Diffstat (limited to 'models/import.js')
-rw-r--r--models/import.js35
1 files changed, 28 insertions, 7 deletions
diff --git a/models/import.js b/models/import.js
index 5095ee2e..e925d028 100644
--- a/models/import.js
+++ b/models/import.js
@@ -21,8 +21,7 @@ class TrelloCreator {
const createdAt = this.createdAt.board;
const boardToCreate = {
archived: trelloBoard.closed,
- // XXX map from Trello colors
- color: Boards.simpleSchema()._schema.color.allowedValues[0],
+ color: this.getColor(trelloBoard.prefs.background),
createdAt,
labels: [],
members: [{
@@ -46,12 +45,14 @@ class TrelloCreator {
this.labels[label.id] = labelToCreate;
boardToCreate.labels.push(labelToCreate);
});
+ const now = new Date();
const boardId = Boards.direct.insert(boardToCreate);
+ Boards.direct.update(boardId, {$set: {modifiedAt: now}});
// log activity
Activities.direct.insert({
activityType: 'importBoard',
boardId,
- createdAt: new Date(),
+ createdAt: now,
source: {
id: trelloBoard.id,
system: 'Trello',
@@ -72,14 +73,17 @@ class TrelloCreator {
title: list.name,
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;
// log activity
Activities.direct.insert({
activityType: 'importList',
boardId,
- createdAt: new Date(),
- listId: listToCreate._id,
+ createdAt: now,
+ listId,
source: {
id: list.id,
system: 'Trello',
@@ -139,6 +143,7 @@ class TrelloCreator {
// XXX use the original comment user instead
userId: Meteor.userId(),
};
+ // dateLastActivity will be set from activity insert, no need to update it ourselves
const commentId = CardComments.direct.insert(commentToCreate);
Activities.direct.insert({
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) {
trelloActions.forEach((action) => {
switch (action.type) {
@@ -202,7 +224,6 @@ Meteor.methods({
const boardId = trelloCreator.createBoardAndLabels(trelloBoard);
trelloCreator.createLists(trelloBoard.lists, boardId);
trelloCreator.createCardsAndComments(trelloBoard.cards, boardId);
- // XXX set modifiedAt or lastActivity
// XXX add members
return boardId;
},