mirror of
https://github.com/wekan/wekan.git
synced 2025-12-20 01:10:12 +01:00
Close #873 by importing checklists from Trello
This commit is contained in:
parent
fd9357a495
commit
4414582a35
1 changed files with 41 additions and 1 deletions
|
|
@ -25,6 +25,8 @@ class TrelloCreator {
|
||||||
this.labels = {};
|
this.labels = {};
|
||||||
// Map of lists Trello ID => Wekan ID
|
// Map of lists Trello ID => Wekan ID
|
||||||
this.lists = {};
|
this.lists = {};
|
||||||
|
// Map of cards Trello ID => Wekan ID
|
||||||
|
this.cards = {};
|
||||||
// The comments, indexed by Trello card id (to map when importing cards)
|
// The comments, indexed by Trello card id (to map when importing cards)
|
||||||
this.comments = {};
|
this.comments = {};
|
||||||
// the members, indexed by Trello member id => Wekan user ID
|
// the members, indexed by Trello member id => Wekan user ID
|
||||||
|
|
@ -119,6 +121,18 @@ class TrelloCreator {
|
||||||
})]);
|
})]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkChecklists(trelloChecklists) {
|
||||||
|
check(trelloChecklists, [Match.ObjectIncluding({
|
||||||
|
idBoard: String,
|
||||||
|
idCard: String,
|
||||||
|
name: String,
|
||||||
|
checkItems: [Match.ObjectIncluding({
|
||||||
|
state: String,
|
||||||
|
name: String
|
||||||
|
})]
|
||||||
|
})]);
|
||||||
|
}
|
||||||
|
|
||||||
// You must call parseActions before calling this one.
|
// You must call parseActions before calling this one.
|
||||||
createBoardAndLabels(trelloBoard) {
|
createBoardAndLabels(trelloBoard) {
|
||||||
const boardToCreate = {
|
const boardToCreate = {
|
||||||
|
|
@ -241,6 +255,8 @@ class TrelloCreator {
|
||||||
}
|
}
|
||||||
// insert card
|
// insert card
|
||||||
const cardId = Cards.direct.insert(cardToCreate);
|
const cardId = Cards.direct.insert(cardToCreate);
|
||||||
|
// keep track of Trello id => WeKan id
|
||||||
|
this.cards[card.id] = cardId;
|
||||||
// log activity
|
// log activity
|
||||||
Activities.direct.insert({
|
Activities.direct.insert({
|
||||||
activityType: 'importCard',
|
activityType: 'importCard',
|
||||||
|
|
@ -280,7 +296,7 @@ class TrelloCreator {
|
||||||
createdAt: this._now(commentToCreate.createdAt),
|
createdAt: this._now(commentToCreate.createdAt),
|
||||||
// we attribute the addComment (not the import)
|
// we attribute the addComment (not the import)
|
||||||
// to the original author - it is needed by some UI elements.
|
// to the original author - it is needed by some UI elements.
|
||||||
userId: commentToCreate.userId,
|
userId: this._user(commentToCreate.userId),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -365,6 +381,28 @@ class TrelloCreator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createChecklists(trelloChecklists) {
|
||||||
|
trelloChecklists.forEach((checklist) => {
|
||||||
|
// Create the checklist
|
||||||
|
const checklistToCreate = {
|
||||||
|
cardId: this.cards[checklist.idCard],
|
||||||
|
title: checklist.name,
|
||||||
|
createdAt: this._now()
|
||||||
|
};
|
||||||
|
const checklistId = Checklists.direct.insert(checklistToCreate);
|
||||||
|
// Now add the items to the checklist
|
||||||
|
const itemsToCreate = [];
|
||||||
|
checklist.checkItems.forEach((item) => {
|
||||||
|
itemsToCreate.push({
|
||||||
|
_id: checklistId + itemsToCreate.length,
|
||||||
|
title: item.name,
|
||||||
|
isFinished: item.state == 'complete'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getAdmin(trelloMemberType) {
|
getAdmin(trelloMemberType) {
|
||||||
return trelloMemberType === 'admin';
|
return trelloMemberType === 'admin';
|
||||||
}
|
}
|
||||||
|
|
@ -446,6 +484,7 @@ Meteor.methods({
|
||||||
trelloCreator.checkLabels(trelloBoard.labels);
|
trelloCreator.checkLabels(trelloBoard.labels);
|
||||||
trelloCreator.checkLists(trelloBoard.lists);
|
trelloCreator.checkLists(trelloBoard.lists);
|
||||||
trelloCreator.checkCards(trelloBoard.cards);
|
trelloCreator.checkCards(trelloBoard.cards);
|
||||||
|
trelloCreator.checkChecklists(trelloBoard.checklists);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Meteor.Error('error-json-schema');
|
throw new Meteor.Error('error-json-schema');
|
||||||
}
|
}
|
||||||
|
|
@ -458,6 +497,7 @@ Meteor.methods({
|
||||||
const boardId = trelloCreator.createBoardAndLabels(trelloBoard);
|
const boardId = trelloCreator.createBoardAndLabels(trelloBoard);
|
||||||
trelloCreator.createLists(trelloBoard.lists, boardId);
|
trelloCreator.createLists(trelloBoard.lists, boardId);
|
||||||
trelloCreator.createCards(trelloBoard.cards, boardId);
|
trelloCreator.createCards(trelloBoard.cards, boardId);
|
||||||
|
trelloCreator.createChecklists(trelloBoard.checklists);
|
||||||
// XXX add members
|
// XXX add members
|
||||||
return boardId;
|
return boardId;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue