mirror of
https://github.com/wekan/wekan.git
synced 2025-04-24 14:08:31 -04:00
Merge branch 'GhassenRjab-export-import-checklists' into devel
Export and import checklists. Thanks to GhassenRjab !
This commit is contained in:
commit
604146b294
3 changed files with 40 additions and 37 deletions
|
@ -3,6 +3,7 @@
|
||||||
This release adds the following new features:
|
This release adds the following new features:
|
||||||
|
|
||||||
* [Export and import attachments as base64 encoded files](https://github.com/wekan/wekan/pull/1134);
|
* [Export and import attachments as base64 encoded files](https://github.com/wekan/wekan/pull/1134);
|
||||||
|
* [Export and import checklists](https://github.com/wekan/wekan/pull/1140);
|
||||||
|
|
||||||
and fixes the following bugs:
|
and fixes the following bugs:
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,10 @@ class Exporter {
|
||||||
result.cards = Cards.find(byBoard, noBoardId).fetch();
|
result.cards = Cards.find(byBoard, noBoardId).fetch();
|
||||||
result.comments = CardComments.find(byBoard, noBoardId).fetch();
|
result.comments = CardComments.find(byBoard, noBoardId).fetch();
|
||||||
result.activities = Activities.find(byBoard, noBoardId).fetch();
|
result.activities = Activities.find(byBoard, noBoardId).fetch();
|
||||||
|
result.checklists = [];
|
||||||
|
result.cards.forEach((card) => {
|
||||||
|
result.checklists.push(...Checklists.find({ cardId: card._id }).fetch());
|
||||||
|
});
|
||||||
// [Old] for attachments we only export IDs and absolute url to original doc
|
// [Old] for attachments we only export IDs and absolute url to original doc
|
||||||
// [New] Encode attachment to base64
|
// [New] Encode attachment to base64
|
||||||
const getBase64Data = function(doc, callback) {
|
const getBase64Data = function(doc, callback) {
|
||||||
|
@ -99,6 +103,7 @@ class Exporter {
|
||||||
});
|
});
|
||||||
result.comments.forEach((comment) => { users[comment.userId] = true; });
|
result.comments.forEach((comment) => { users[comment.userId] = true; });
|
||||||
result.activities.forEach((activity) => { users[activity.userId] = true; });
|
result.activities.forEach((activity) => { users[activity.userId] = true; });
|
||||||
|
result.checklists.forEach((checklist) => { users[checklist.userId] = true; });
|
||||||
const byUserIds = { _id: { $in: Object.getOwnPropertyNames(users) } };
|
const byUserIds = { _id: { $in: Object.getOwnPropertyNames(users) } };
|
||||||
// we use whitelist to be sure we do not expose inadvertently
|
// we use whitelist to be sure we do not expose inadvertently
|
||||||
// some secret fields that gets added to User later.
|
// some secret fields that gets added to User later.
|
||||||
|
|
|
@ -116,17 +116,16 @@ export class WekanCreator {
|
||||||
})]);
|
})]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkChecklists(wekanChecklists) {
|
checkChecklists(wekanChecklists) {
|
||||||
// check(wekanChecklists, [Match.ObjectIncluding({
|
check(wekanChecklists, [Match.ObjectIncluding({
|
||||||
// idBoard: String,
|
cardId: String,
|
||||||
// idCard: String,
|
title: String,
|
||||||
// name: String,
|
items: [Match.ObjectIncluding({
|
||||||
// checkItems: [Match.ObjectIncluding({
|
isFinished: Boolean,
|
||||||
// state: String,
|
title: String,
|
||||||
// name: String,
|
})],
|
||||||
// })],
|
})]);
|
||||||
// })]);
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// You must call parseActions before calling this one.
|
// You must call parseActions before calling this one.
|
||||||
createBoardAndLabels(wekanBoard) {
|
createBoardAndLabels(wekanBoard) {
|
||||||
|
@ -248,7 +247,7 @@ export class WekanCreator {
|
||||||
// insert card
|
// insert card
|
||||||
const cardId = Cards.direct.insert(cardToCreate);
|
const cardId = Cards.direct.insert(cardToCreate);
|
||||||
// keep track of Wekan id => WeKan id
|
// keep track of Wekan id => WeKan id
|
||||||
this.cards[card.id] = cardId;
|
this.cards[card._id] = cardId;
|
||||||
// log activity
|
// log activity
|
||||||
Activities.direct.insert({
|
Activities.direct.insert({
|
||||||
activityType: 'importCard',
|
activityType: 'importCard',
|
||||||
|
@ -391,27 +390,27 @@ export class WekanCreator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// createChecklists(wekanChecklists) {
|
createChecklists(wekanChecklists) {
|
||||||
// wekanChecklists.forEach((checklist) => {
|
wekanChecklists.forEach((checklist) => {
|
||||||
// // Create the checklist
|
// Create the checklist
|
||||||
// const checklistToCreate = {
|
const checklistToCreate = {
|
||||||
// cardId: this.cards[checklist.cardId],
|
cardId: this.cards[checklist.cardId],
|
||||||
// title: checklist.title,
|
title: checklist.title,
|
||||||
// createdAt: this._now(),
|
createdAt: checklist.createdAt,
|
||||||
// };
|
};
|
||||||
// const checklistId = Checklists.direct.insert(checklistToCreate);
|
const checklistId = Checklists.direct.insert(checklistToCreate);
|
||||||
// // Now add the items to the checklist
|
// Now add the items to the checklist
|
||||||
// const itemsToCreate = [];
|
const itemsToCreate = [];
|
||||||
// checklist.checkItems.forEach((item) => {
|
checklist.items.forEach((item) => {
|
||||||
// itemsToCreate.push({
|
itemsToCreate.push({
|
||||||
// _id: checklistId + itemsToCreate.length,
|
_id: checklistId + itemsToCreate.length,
|
||||||
// title: item.title,
|
title: item.title,
|
||||||
// isFinished: item.isFinished,
|
isFinished: item.isFinished,
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}});
|
Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}});
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
parseActivities(wekanBoard) {
|
parseActivities(wekanBoard) {
|
||||||
wekanBoard.activities.forEach((activity) => {
|
wekanBoard.activities.forEach((activity) => {
|
||||||
|
@ -473,8 +472,7 @@ export class WekanCreator {
|
||||||
this.checkLabels(board.labels);
|
this.checkLabels(board.labels);
|
||||||
this.checkLists(board.lists);
|
this.checkLists(board.lists);
|
||||||
this.checkCards(board.cards);
|
this.checkCards(board.cards);
|
||||||
// Checklists are not exported yet
|
this.checkChecklists(board.checklists);
|
||||||
// this.checkChecklists(board.checklists);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Meteor.Error('error-json-schema');
|
throw new Meteor.Error('error-json-schema');
|
||||||
}
|
}
|
||||||
|
@ -485,8 +483,7 @@ export class WekanCreator {
|
||||||
const boardId = this.createBoardAndLabels(board);
|
const boardId = this.createBoardAndLabels(board);
|
||||||
this.createLists(board.lists, boardId);
|
this.createLists(board.lists, boardId);
|
||||||
this.createCards(board.cards, boardId);
|
this.createCards(board.cards, boardId);
|
||||||
// Checklists are not exported yet
|
this.createChecklists(board.checklists);
|
||||||
// this.createChecklists(board.checklists);
|
|
||||||
// XXX add members
|
// XXX add members
|
||||||
return boardId;
|
return boardId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue