mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Import single card: create an 'importCard' activity entry
This commit is contained in:
parent
4b99ce2aa2
commit
7d57ce896b
4 changed files with 35 additions and 8 deletions
|
|
@ -26,6 +26,9 @@ template(name="boardActivities")
|
||||||
if($eq activityType 'createCard')
|
if($eq activityType 'createCard')
|
||||||
| {{{_ 'activity-added' cardLink boardLabel}}}.
|
| {{{_ 'activity-added' cardLink boardLabel}}}.
|
||||||
|
|
||||||
|
if($eq activityType 'importCard')
|
||||||
|
| {{{_ 'activity-imported' cardLink boardLabel sourceLink}}}.
|
||||||
|
|
||||||
if($eq activityType 'archivedCard')
|
if($eq activityType 'archivedCard')
|
||||||
| {{{_ 'activity-archived' cardLink}}}.
|
| {{{_ 'activity-archived' cardLink}}}.
|
||||||
|
|
||||||
|
|
@ -72,6 +75,8 @@ template(name="cardActivities")
|
||||||
+memberName(user=user)
|
+memberName(user=user)
|
||||||
if($eq activityType 'createCard')
|
if($eq activityType 'createCard')
|
||||||
| {{_ 'activity-added' cardLabel list.title}}.
|
| {{_ 'activity-added' cardLabel list.title}}.
|
||||||
|
if($eq activityType 'importCard')
|
||||||
|
| {{{_ 'activity-imported' cardLabel list.title sourceLink}}}.
|
||||||
if($eq activityType 'joinMember')
|
if($eq activityType 'joinMember')
|
||||||
if($eq currentUser._id member._id)
|
if($eq currentUser._id member._id)
|
||||||
| {{_ 'activity-joined' cardLabel}}.
|
| {{_ 'activity-joined' cardLabel}}.
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,13 @@ BlazeComponent.extendComponent({
|
||||||
}, card.title));
|
}, card.title));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
sourceLink() {
|
||||||
|
const source = this.currentData().source;
|
||||||
|
return source && Blaze.toHTML(HTML.A({
|
||||||
|
href: source.url,
|
||||||
|
}, source.system));
|
||||||
|
},
|
||||||
|
|
||||||
memberLink() {
|
memberLink() {
|
||||||
return Blaze.toHTMLWithData(Template.memberName, {
|
return Blaze.toHTMLWithData(Template.memberName, {
|
||||||
user: this.currentData().member(),
|
user: this.currentData().member(),
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
"activity-attached": "attached %s to %s",
|
"activity-attached": "attached %s to %s",
|
||||||
"activity-created": "created %s",
|
"activity-created": "created %s",
|
||||||
"activity-excluded": "excluded %s from %s",
|
"activity-excluded": "excluded %s from %s",
|
||||||
|
"activity-imported": "imported %s into %s from %s",
|
||||||
"activity-joined": "joined %s",
|
"activity-joined": "joined %s",
|
||||||
"activity-moved": "moved %s from %s to %s",
|
"activity-moved": "moved %s from %s to %s",
|
||||||
"activity-on": "on %s",
|
"activity-on": "on %s",
|
||||||
|
|
|
||||||
|
|
@ -41,16 +41,17 @@ Meteor.methods({
|
||||||
// 3. map all fields for the card to create
|
// 3. map all fields for the card to create
|
||||||
const dateOfImport = new Date();
|
const dateOfImport = new Date();
|
||||||
const cardToCreate = {
|
const cardToCreate = {
|
||||||
title: trelloCard.name,
|
|
||||||
description: trelloCard.desc,
|
|
||||||
listId: list._id,
|
|
||||||
boardId: list.boardId,
|
|
||||||
userId: Meteor.userId(),
|
|
||||||
sort: sortIndex,
|
|
||||||
archived: trelloCard.closed,
|
archived: trelloCard.closed,
|
||||||
|
boardId: list.boardId,
|
||||||
// this is a default date, we'll fetch the actual one from the actions array
|
// this is a default date, we'll fetch the actual one from the actions array
|
||||||
createdAt: dateOfImport,
|
createdAt: dateOfImport,
|
||||||
dateLastActivity: dateOfImport,
|
dateLastActivity: dateOfImport,
|
||||||
|
description: trelloCard.desc,
|
||||||
|
listId: list._id,
|
||||||
|
sort: sortIndex,
|
||||||
|
title: trelloCard.name,
|
||||||
|
// XXX use the original user?
|
||||||
|
userId: Meteor.userId(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// 4. find actual creation date
|
// 4. find actual creation date
|
||||||
|
|
@ -84,7 +85,20 @@ Meteor.methods({
|
||||||
|
|
||||||
// 6. insert new card into list
|
// 6. insert new card into list
|
||||||
const cardId = Cards.direct.insert(cardToCreate);
|
const cardId = Cards.direct.insert(cardToCreate);
|
||||||
// XXX then add import activity
|
Activities.direct.insert({
|
||||||
|
activityType: 'importCard',
|
||||||
|
boardId: cardToCreate.boardId,
|
||||||
|
cardId: cardId,
|
||||||
|
createdAt: dateOfImport,
|
||||||
|
listId: cardToCreate.listId,
|
||||||
|
source: {
|
||||||
|
id: trelloCard.id,
|
||||||
|
system: 'Trello',
|
||||||
|
url: trelloCard.url,
|
||||||
|
},
|
||||||
|
// we attribute the import to current user, not the one from the original card
|
||||||
|
userId: Meteor.userId(),
|
||||||
|
});
|
||||||
|
|
||||||
// 7. parse actions and add comments
|
// 7. parse actions and add comments
|
||||||
trelloCard.actions.forEach((currentAction) => {
|
trelloCard.actions.forEach((currentAction) => {
|
||||||
|
|
@ -94,6 +108,7 @@ Meteor.methods({
|
||||||
cardId: cardId,
|
cardId: cardId,
|
||||||
createdAt: currentAction.date,
|
createdAt: currentAction.date,
|
||||||
text: currentAction.data.text,
|
text: currentAction.data.text,
|
||||||
|
// XXX use the original comment user instead
|
||||||
userId: Meteor.userId(),
|
userId: Meteor.userId(),
|
||||||
};
|
};
|
||||||
const commentId = CardComments.direct.insert(commentToCreate);
|
const commentId = CardComments.direct.insert(commentToCreate);
|
||||||
|
|
@ -106,7 +121,6 @@ Meteor.methods({
|
||||||
userId: commentToCreate.userId,
|
userId: commentToCreate.userId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// XXX add other type of activities?
|
|
||||||
});
|
});
|
||||||
return cardId;
|
return cardId;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue