mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Import single card: now uses historical dates
This commit is contained in:
parent
d8892d6408
commit
81bd551137
1 changed files with 20 additions and 11 deletions
|
|
@ -38,7 +38,6 @@ Meteor.methods({
|
||||||
|
|
||||||
// 1. map all fields for the card to create
|
// 1. map all fields for the card to create
|
||||||
const dateOfImport = new Date();
|
const dateOfImport = new Date();
|
||||||
// XXX parse trelloCard.actions to determine creation date
|
|
||||||
const cardToCreate = {
|
const cardToCreate = {
|
||||||
title: trelloCard.name,
|
title: trelloCard.name,
|
||||||
description: trelloCard.desc,
|
description: trelloCard.desc,
|
||||||
|
|
@ -47,10 +46,15 @@ Meteor.methods({
|
||||||
userId: Meteor.userId(),
|
userId: Meteor.userId(),
|
||||||
sort: sortIndex,
|
sort: sortIndex,
|
||||||
archived: trelloCard.closed,
|
archived: trelloCard.closed,
|
||||||
// XXX dateOfImport
|
// this is a default date, we'll fetch the actual one from the actions array
|
||||||
createdAt: dateOfImport,
|
createdAt: dateOfImport,
|
||||||
dateLastActivity: 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
|
// 2. map labels
|
||||||
trelloCard.labels.forEach((currentLabel) => {
|
trelloCard.labels.forEach((currentLabel) => {
|
||||||
const color = currentLabel.color;
|
const color = currentLabel.color;
|
||||||
|
|
@ -74,25 +78,30 @@ Meteor.methods({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 3. insert new card into list
|
// 3. insert new card into list
|
||||||
// XXX replace with direct MongoDB inserts
|
const cardId = Cards.direct.insert(cardToCreate);
|
||||||
const _id = Cards.direct.insert(cardToCreate);
|
|
||||||
// XXX then add import activity
|
// XXX then add import activity
|
||||||
// 4. parse actions and add comments
|
// 4. parse actions and add comments
|
||||||
trelloCard.actions.forEach((currentAction) => {
|
trelloCard.actions.forEach((currentAction) => {
|
||||||
if(currentAction.type === 'commentCard') {
|
if(currentAction.type === 'commentCard') {
|
||||||
const commentToCreate = {
|
const commentToCreate = {
|
||||||
boardId: list.boardId,
|
boardId: list.boardId,
|
||||||
cardId: _id,
|
cardId: cardId,
|
||||||
userId: Meteor.userId(),
|
|
||||||
text: currentAction.data.text,
|
|
||||||
createdAt: currentAction.date,
|
createdAt: currentAction.date,
|
||||||
|
text: currentAction.data.text,
|
||||||
|
userId: Meteor.userId(),
|
||||||
};
|
};
|
||||||
// console.log(commentToCreate);
|
const commentId = CardComments.direct.insert(commentToCreate);
|
||||||
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 add other type of activities?
|
||||||
// XXX look for createCard to set create date > no do it BEFORE saving
|
|
||||||
});
|
});
|
||||||
return _id;
|
return cardId;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue