summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorXavier Priour <xavier.priour@bubblyware.com>2015-11-13 15:52:14 +0100
committerXavier Priour <xavier.priour@bubblyware.com>2015-11-13 15:52:14 +0100
commitf6f41270de1b5a2d3ff6aa4ca7d433915dd29bd9 (patch)
treec585436d6736dcdd3cbac5e81cffa8bb3b45bae1 /models
parenta7427b9ae4e790989c49408ffe14aea4976db305 (diff)
downloadwekan-f6f41270de1b5a2d3ff6aa4ca7d433915dd29bd9.tar.gz
wekan-f6f41270de1b5a2d3ff6aa4ca7d433915dd29bd9.tar.bz2
wekan-f6f41270de1b5a2d3ff6aa4ca7d433915dd29bd9.zip
Import members: working on card import
Diffstat (limited to 'models')
-rw-r--r--models/import.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/models/import.js b/models/import.js
index a6e9f3d5..ab23f0a9 100644
--- a/models/import.js
+++ b/models/import.js
@@ -4,7 +4,7 @@ const DateString = Match.Where(function (dateAsString) {
});
class TrelloCreator {
- constructor() {
+ constructor(data) {
// The object creation dates, indexed by Trello id (so we only parse actions
// once!)
this.createdAt = {
@@ -18,6 +18,8 @@ class TrelloCreator {
this.lists = {};
// The comments, indexed by Trello card id (to map when importing cards)
this.comments = {};
+ // the members, indexed by Trello member id => Wekan user ID
+ this.members = data.membersMapping ? data.membersMapping : {};
}
checkActions(trelloActions) {
@@ -191,6 +193,19 @@ class TrelloCreator {
return this.labels[trelloId];
});
}
+ // add members {
+ if(card.idMembers) {
+ const wekanMembers = [];
+ // we can't just map, as some members may not have been mapped
+ card.idMembers.forEach((id) => {
+ if(this.members[id]) {
+ wekanMembers.push(this.members[id]);
+ }
+ });
+ if(wekanMembers.length>0) {
+ cardToCreate.members = wekanMembers;
+ }
+ }
// insert card
const cardId = Cards.direct.insert(cardToCreate);
// log activity
@@ -298,7 +313,7 @@ class TrelloCreator {
Meteor.methods({
importTrelloBoard(trelloBoard, data) {
- const trelloCreator = new TrelloCreator();
+ const trelloCreator = new TrelloCreator(data);
// 1. check all parameters are ok from a syntax point of view
try {
@@ -326,13 +341,14 @@ Meteor.methods({
},
importTrelloCard(trelloCard, data) {
- const trelloCreator = new TrelloCreator();
+ const trelloCreator = new TrelloCreator(data);
// 1. check parameters are ok from a syntax point of view
try {
check(data, {
listId: String,
sortIndex: Number,
+ membersMapping: Match.Optional(Object),
});
trelloCreator.checkCards([trelloCard]);
trelloCreator.checkLabels(trelloCard.labels);