From 3eb4d2c341b712268bd321173909e0a7b19a88c9 Mon Sep 17 00:00:00 2001 From: Justin Reynolds Date: Fri, 28 Jun 2019 12:52:09 -0500 Subject: Prettier & eslint project style update --- models/export.js | 125 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 48 deletions(-) (limited to 'models/export.js') diff --git a/models/export.js b/models/export.js index 8e5ce786..a69be970 100644 --- a/models/export.js +++ b/models/export.js @@ -57,7 +57,10 @@ export class Exporter { build() { const byBoard = { boardId: this._boardId }; - const byBoardNoLinked = { boardId: this._boardId, linkedId: {$in: ['', null] } }; + const byBoardNoLinked = { + boardId: this._boardId, + linkedId: { $in: ['', null] }, + }; // we do not want to retrieve boardId in related elements const noBoardId = { fields: { @@ -67,15 +70,21 @@ export class Exporter { const result = { _format: 'wekan-board-1.0.0', }; - _.extend(result, Boards.findOne(this._boardId, { - fields: { - stars: 0, - }, - })); + _.extend( + result, + Boards.findOne(this._boardId, { + fields: { + stars: 0, + }, + }), + ); result.lists = Lists.find(byBoard, noBoardId).fetch(); result.cards = Cards.find(byBoardNoLinked, noBoardId).fetch(); result.swimlanes = Swimlanes.find(byBoard, noBoardId).fetch(); - result.customFields = CustomFields.find({boardIds: {$in: [this.boardId]}}, {fields: {boardId: 0}}).fetch(); + result.customFields = CustomFields.find( + { boardIds: { $in: [this.boardId] } }, + { fields: { boardId: 0 } }, + ).fetch(); result.comments = CardComments.find(byBoard, noBoardId).fetch(); result.activities = Activities.find(byBoard, noBoardId).fetch(); result.rules = Rules.find(byBoard, noBoardId).fetch(); @@ -84,24 +93,40 @@ export class Exporter { result.subtaskItems = []; result.triggers = []; result.actions = []; - result.cards.forEach((card) => { - result.checklists.push(...Checklists.find({ - cardId: card._id, - }).fetch()); - result.checklistItems.push(...ChecklistItems.find({ - cardId: card._id, - }).fetch()); - result.subtaskItems.push(...Cards.find({ - parentid: card._id, - }).fetch()); + result.cards.forEach(card => { + result.checklists.push( + ...Checklists.find({ + cardId: card._id, + }).fetch(), + ); + result.checklistItems.push( + ...ChecklistItems.find({ + cardId: card._id, + }).fetch(), + ); + result.subtaskItems.push( + ...Cards.find({ + parentid: card._id, + }).fetch(), + ); }); - result.rules.forEach((rule) => { - result.triggers.push(...Triggers.find({ - _id: rule.triggerId, - }, noBoardId).fetch()); - result.actions.push(...Actions.find({ - _id: rule.actionId, - }, noBoardId).fetch()); + result.rules.forEach(rule => { + result.triggers.push( + ...Triggers.find( + { + _id: rule.triggerId, + }, + noBoardId, + ).fetch(), + ); + result.actions.push( + ...Actions.find( + { + _id: rule.actionId, + }, + noBoardId, + ).fetch(), + ); }); // [Old] for attachments we only export IDs and absolute url to original doc @@ -122,43 +147,45 @@ export class Exporter { }); }; const getBase64DataSync = Meteor.wrapAsync(getBase64Data); - result.attachments = Attachments.find(byBoard).fetch().map((attachment) => { - return { - _id: attachment._id, - cardId: attachment.cardId, - // url: FlowRouter.url(attachment.url()), - file: getBase64DataSync(attachment), - name: attachment.original.name, - type: attachment.original.type, - }; - }); + result.attachments = Attachments.find(byBoard) + .fetch() + .map(attachment => { + return { + _id: attachment._id, + cardId: attachment.cardId, + // url: FlowRouter.url(attachment.url()), + file: getBase64DataSync(attachment), + name: attachment.original.name, + type: attachment.original.type, + }; + }); // we also have to export some user data - as the other elements only // include id but we have to be careful: // 1- only exports users that are linked somehow to that board // 2- do not export any sensitive information const users = {}; - result.members.forEach((member) => { + result.members.forEach(member => { users[member.userId] = true; }); - result.lists.forEach((list) => { + result.lists.forEach(list => { users[list.userId] = true; }); - result.cards.forEach((card) => { + result.cards.forEach(card => { users[card.userId] = true; if (card.members) { - card.members.forEach((memberId) => { + card.members.forEach(memberId => { users[memberId] = true; }); } }); - result.comments.forEach((comment) => { + result.comments.forEach(comment => { users[comment.userId] = true; }); - result.activities.forEach((activity) => { + result.activities.forEach(activity => { users[activity.userId] = true; }); - result.checklists.forEach((checklist) => { + result.checklists.forEach(checklist => { users[checklist.userId] = true; }); const byUserIds = { @@ -177,13 +204,15 @@ export class Exporter { 'profile.avatarUrl': 1, }, }; - result.users = Users.find(byUserIds, userFields).fetch().map((user) => { - // user avatar is stored as a relative url, we export absolute - if ((user.profile || {}).avatarUrl) { - user.profile.avatarUrl = FlowRouter.url(user.profile.avatarUrl); - } - return user; - }); + result.users = Users.find(byUserIds, userFields) + .fetch() + .map(user => { + // user avatar is stored as a relative url, we export absolute + if ((user.profile || {}).avatarUrl) { + user.profile.avatarUrl = FlowRouter.url(user.profile.avatarUrl); + } + return user; + }); return result; } -- cgit v1.2.3-1-g7c22