summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Priour <xavier.priour@bubblyware.com>2015-10-14 18:23:46 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-10-14 23:23:16 +0200
commit81bd55113789e53e65080604bb29a3d61df83684 (patch)
treeb0a221455a85b13981c564c2ae430339aae39ebf
parentd8892d640860b77795b1e81d2ba121cf65d35373 (diff)
downloadwekan-81bd55113789e53e65080604bb29a3d61df83684.tar.gz
wekan-81bd55113789e53e65080604bb29a3d61df83684.tar.bz2
wekan-81bd55113789e53e65080604bb29a3d61df83684.zip
Import single card: now uses historical dates
-rw-r--r--models/import.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/models/import.js b/models/import.js
index 83559078..28b02805 100644
--- a/models/import.js
+++ b/models/import.js
@@ -38,7 +38,6 @@ Meteor.methods({
// 1. map all fields for the card to create
const dateOfImport = new Date();
- // XXX parse trelloCard.actions to determine creation date
const cardToCreate = {
title: trelloCard.name,
description: trelloCard.desc,
@@ -47,10 +46,15 @@ Meteor.methods({
userId: Meteor.userId(),
sort: sortIndex,
archived: trelloCard.closed,
- // XXX dateOfImport
+ // this is a default date, we'll fetch the actual one from the actions array
createdAt: dateOfImport,
dateLastActivity: dateOfImport,
};
+ // find actual creation date
+ const creationAction = trelloCard.actions.find((action) => {return action.type === 'createCard';});
+ if(creationAction) {
+ cardToCreate.createdAt = creationAction.date;
+ }
// 2. map labels
trelloCard.labels.forEach((currentLabel) => {
const color = currentLabel.color;
@@ -74,25 +78,30 @@ Meteor.methods({
}
});
// 3. insert new card into list
- // XXX replace with direct MongoDB inserts
- const _id = Cards.direct.insert(cardToCreate);
+ const cardId = Cards.direct.insert(cardToCreate);
// XXX then add import activity
// 4. parse actions and add comments
trelloCard.actions.forEach((currentAction) => {
if(currentAction.type === 'commentCard') {
const commentToCreate = {
boardId: list.boardId,
- cardId: _id,
- userId: Meteor.userId(),
- text: currentAction.data.text,
+ cardId: cardId,
createdAt: currentAction.date,
+ text: currentAction.data.text,
+ userId: Meteor.userId(),
};
- // console.log(commentToCreate);
- CardComments.direct.insert(commentToCreate);
+ const commentId = CardComments.direct.insert(commentToCreate);
+ Activities.direct.insert({
+ activityType: 'addComment',
+ boardId: commentToCreate.boardId,
+ cardId: commentToCreate.cardId,
+ commentId: commentId,
+ createdAt: commentToCreate.createdAt,
+ userId: commentToCreate.userId,
+ });
}
// XXX add other type of activities?
- // XXX look for createCard to set create date > no do it BEFORE saving
});
- return _id;
+ return cardId;
},
});