summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/actions.js26
-rw-r--r--models/activities.js7
-rw-r--r--models/attachments.js12
-rw-r--r--models/cards.js168
-rw-r--r--models/checklistItems.js45
-rw-r--r--models/checklists.js4
-rw-r--r--models/export.js24
-rw-r--r--models/rules.js5
-rw-r--r--models/triggers.js14
-rw-r--r--models/wekanCreator.js376
10 files changed, 338 insertions, 343 deletions
diff --git a/models/actions.js b/models/actions.js
index 82ab0d19..0430b044 100644
--- a/models/actions.js
+++ b/models/actions.js
@@ -1,19 +1,19 @@
Actions = new Mongo.Collection('actions');
Actions.allow({
- insert(userId, doc) {
- return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
- },
- update(userId, doc) {
- return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
- },
- remove(userId, doc) {
- return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
- }
+ insert(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
+ update(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
+ remove(userId, doc) {
+ return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
+ },
});
Actions.helpers({
- description() {
- return this.desc;
- }
-}); \ No newline at end of file
+ description() {
+ return this.desc;
+ },
+});
diff --git a/models/activities.js b/models/activities.js
index c14760c2..c3c8f173 100644
--- a/models/activities.js
+++ b/models/activities.js
@@ -57,16 +57,13 @@ Activities.before.insert((userId, doc) => {
});
-
Activities.after.insert((userId, doc) => {
- const activity = Activities._transform(doc);
- RulesHelper.executeRules(activity);
+ const activity = Activities._transform(doc);
+ RulesHelper.executeRules(activity);
});
-
-
if (Meteor.isServer) {
// For efficiency create indexes on the date of creation, and on the date of
// creation in conjunction with the card or board id, as corresponding views
diff --git a/models/attachments.js b/models/attachments.js
index d769de34..3da067de 100644
--- a/models/attachments.js
+++ b/models/attachments.js
@@ -87,11 +87,11 @@ if (Meteor.isServer) {
attachmentId: doc._id,
});
Activities.insert({
- userId,
- type: 'card',
- activityType: 'deleteAttachment',
- boardId: doc.boardId,
- cardId: doc.cardId,
- });
+ userId,
+ type: 'card',
+ activityType: 'deleteAttachment',
+ boardId: doc.boardId,
+ cardId: doc.cardId,
+ });
});
}
diff --git a/models/cards.js b/models/cards.js
index 0754b2bb..346b4bdd 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -278,8 +278,8 @@ Cards.helpers({
archived: false,
}, {
sort: {
- sort: 1
- }
+ sort: 1,
+ },
});
},
@@ -289,8 +289,8 @@ Cards.helpers({
archived: false,
}, {
sort: {
- sort: 1
- }
+ sort: 1,
+ },
});
},
@@ -304,7 +304,7 @@ Cards.helpers({
subtasksFinishedCount() {
return Cards.find({
parentId: this._id,
- archived: true
+ archived: true,
}).count();
},
@@ -365,7 +365,7 @@ Cards.helpers({
canBeRestored() {
const list = Lists.findOne({
- _id: this.listId
+ _id: this.listId,
});
if (!list.getWipLimit('soft') && list.getWipLimit('enabled') && list.getWipLimit('value') === list.cards().count()) {
return false;
@@ -835,7 +835,7 @@ Cards.helpers({
Cards.mutations({
applyToChildren(funct) {
Cards.find({
- parentId: this._id
+ parentId: this._id,
}).forEach((card) => {
funct(card);
});
@@ -847,8 +847,8 @@ Cards.mutations({
});
return {
$set: {
- archived: true
- }
+ archived: true,
+ },
};
},
@@ -858,40 +858,40 @@ Cards.mutations({
});
return {
$set: {
- archived: false
- }
+ archived: false,
+ },
};
},
setTitle(title) {
return {
$set: {
- title
- }
+ title,
+ },
};
},
setDescription(description) {
return {
$set: {
- description
- }
+ description,
+ },
};
},
setRequestedBy(requestedBy) {
return {
$set: {
- requestedBy
- }
+ requestedBy,
+ },
};
},
setAssignedBy(assignedBy) {
return {
$set: {
- assignedBy
- }
+ assignedBy,
+ },
};
},
@@ -905,23 +905,23 @@ Cards.mutations({
};
return {
- $set: mutatedFields
+ $set: mutatedFields,
};
},
addLabel(labelId) {
return {
$addToSet: {
- labelIds: labelId
- }
+ labelIds: labelId,
+ },
};
},
removeLabel(labelId) {
return {
$pull: {
- labelIds: labelId
- }
+ labelIds: labelId,
+ },
};
},
@@ -936,16 +936,16 @@ Cards.mutations({
assignMember(memberId) {
return {
$addToSet: {
- members: memberId
- }
+ members: memberId,
+ },
};
},
unassignMember(memberId) {
return {
$pull: {
- members: memberId
- }
+ members: memberId,
+ },
};
},
@@ -962,9 +962,9 @@ Cards.mutations({
$addToSet: {
customFields: {
_id: customFieldId,
- value: null
- }
- }
+ value: null,
+ },
+ },
};
},
@@ -972,9 +972,9 @@ Cards.mutations({
return {
$pull: {
customFields: {
- _id: customFieldId
- }
- }
+ _id: customFieldId,
+ },
+ },
};
},
@@ -991,7 +991,7 @@ Cards.mutations({
const index = this.customFieldIndex(customFieldId);
if (index > -1) {
const update = {
- $set: {}
+ $set: {},
};
update.$set[`customFields.${index}.value`] = value;
return update;
@@ -1004,96 +1004,96 @@ Cards.mutations({
setCover(coverId) {
return {
$set: {
- coverId
- }
+ coverId,
+ },
};
},
unsetCover() {
return {
$unset: {
- coverId: ''
- }
+ coverId: '',
+ },
};
},
setReceived(receivedAt) {
return {
$set: {
- receivedAt
- }
+ receivedAt,
+ },
};
},
unsetReceived() {
return {
$unset: {
- receivedAt: ''
- }
+ receivedAt: '',
+ },
};
},
setStart(startAt) {
return {
$set: {
- startAt
- }
+ startAt,
+ },
};
},
unsetStart() {
return {
$unset: {
- startAt: ''
- }
+ startAt: '',
+ },
};
},
setDue(dueAt) {
return {
$set: {
- dueAt
- }
+ dueAt,
+ },
};
},
unsetDue() {
return {
$unset: {
- dueAt: ''
- }
+ dueAt: '',
+ },
};
},
setEnd(endAt) {
return {
$set: {
- endAt
- }
+ endAt,
+ },
};
},
unsetEnd() {
return {
$unset: {
- endAt: ''
- }
+ endAt: '',
+ },
};
},
setOvertime(isOvertime) {
return {
$set: {
- isOvertime
- }
+ isOvertime,
+ },
};
},
setSpentTime(spentTime) {
return {
$set: {
- spentTime
- }
+ spentTime,
+ },
};
},
@@ -1101,16 +1101,16 @@ Cards.mutations({
return {
$unset: {
spentTime: '',
- isOvertime: false
- }
+ isOvertime: false,
+ },
};
},
setParentId(parentId) {
return {
$set: {
- parentId
- }
+ parentId,
+ },
};
},
});
@@ -1206,7 +1206,7 @@ function cardLabels(userId, doc, fieldNames, modifier) {
activityType: 'addedLabel',
boardId: doc.boardId,
cardId: doc._id,
- }
+ };
Activities.insert(act);
}
}
@@ -1313,7 +1313,7 @@ if (Meteor.isServer) {
data: Cards.find({
boardId: paramBoardId,
listId: paramListId,
- archived: false
+ archived: false,
}).map(function(doc) {
return {
_id: doc._id,
@@ -1335,7 +1335,7 @@ if (Meteor.isServer) {
_id: paramCardId,
listId: paramListId,
boardId: paramBoardId,
- archived: false
+ archived: false,
}),
});
});
@@ -1345,7 +1345,7 @@ if (Meteor.isServer) {
const paramBoardId = req.params.boardId;
const paramListId = req.params.listId;
const check = Users.findOne({
- _id: req.body.authorId
+ _id: req.body.authorId,
});
const members = req.body.members || [req.body.authorId];
if (typeof check !== 'undefined') {
@@ -1367,7 +1367,7 @@ if (Meteor.isServer) {
});
const card = Cards.findOne({
- _id: id
+ _id: id,
});
cardCreation(req.body.authorId, card);
@@ -1390,11 +1390,11 @@ if (Meteor.isServer) {
_id: paramCardId,
listId: paramListId,
boardId: paramBoardId,
- archived: false
+ archived: false,
}, {
$set: {
- title: newTitle
- }
+ title: newTitle,
+ },
});
}
if (req.body.hasOwnProperty('listId')) {
@@ -1403,18 +1403,18 @@ if (Meteor.isServer) {
_id: paramCardId,
listId: paramListId,
boardId: paramBoardId,
- archived: false
+ archived: false,
}, {
$set: {
- listId: newParamListId
- }
+ listId: newParamListId,
+ },
});
const card = Cards.findOne({
- _id: paramCardId
+ _id: paramCardId,
});
cardMove(req.body.authorId, card, {
- fieldName: 'listId'
+ fieldName: 'listId',
}, paramListId);
}
@@ -1424,11 +1424,11 @@ if (Meteor.isServer) {
_id: paramCardId,
listId: paramListId,
boardId: paramBoardId,
- archived: false
+ archived: false,
}, {
$set: {
- description: newDescription
- }
+ description: newDescription,
+ },
});
}
if (req.body.hasOwnProperty('labelIds')) {
@@ -1437,11 +1437,11 @@ if (Meteor.isServer) {
_id: paramCardId,
listId: paramListId,
boardId: paramBoardId,
- archived: false
+ archived: false,
}, {
$set: {
- labelIds: newlabelIds
- }
+ labelIds: newlabelIds,
+ },
});
}
if (req.body.hasOwnProperty('requestedBy')) {
@@ -1506,10 +1506,10 @@ if (Meteor.isServer) {
Cards.direct.remove({
_id: paramCardId,
listId: paramListId,
- boardId: paramBoardId
+ boardId: paramBoardId,
});
const card = Cards.find({
- _id: paramCardId
+ _id: paramCardId,
});
cardRemover(req.body.authorId, card);
JsonRoutes.sendResult(res, {
diff --git a/models/checklistItems.js b/models/checklistItems.js
index 1657022b..8380bda7 100644
--- a/models/checklistItems.js
+++ b/models/checklistItems.js
@@ -76,7 +76,7 @@ function itemCreation(userId, doc) {
boardId,
checklistId: doc.checklistId,
checklistItemId: doc._id,
- checklistItemName:doc.title
+ checklistItemName:doc.title,
});
}
@@ -90,66 +90,66 @@ function itemRemover(userId, doc) {
boardId,
checklistId: doc.checklistId,
checklistItemId: doc._id,
- checklistItemName:doc.title
+ checklistItemName:doc.title,
});
Activities.remove({
checklistItemId: doc._id,
});
}
-function publishCheckActivity(userId,doc){
+function publishCheckActivity(userId, doc){
const card = Cards.findOne(doc.cardId);
const boardId = card.boardId;
let activityType;
if(doc.isFinished){
- activityType = "checkedItem";
+ activityType = 'checkedItem';
}else{
- activityType = "uncheckedItem";
+ activityType = 'uncheckedItem';
}
- let act = {
+ const act = {
userId,
- activityType: activityType,
+ activityType,
cardId: doc.cardId,
boardId,
checklistId: doc.checklistId,
checklistItemId: doc._id,
- checklistItemName:doc.title
- }
+ checklistItemName:doc.title,
+ };
Activities.insert(act);
}
-function publishChekListCompleted(userId,doc,fieldNames,modifier){
+function publishChekListCompleted(userId, doc, fieldNames, modifier){
const card = Cards.findOne(doc.cardId);
const boardId = card.boardId;
const checklistId = doc.checklistId;
const checkList = Checklists.findOne({_id:checklistId});
if(checkList.isFinished()){
- let act = {
+ const act = {
userId,
- activityType: "checklistCompleted",
+ activityType: 'checklistCompleted',
cardId: doc.cardId,
boardId,
checklistId: doc.checklistId,
- checklistName:doc.title
- }
+ checklistName:doc.title,
+ };
Activities.insert(act);
}
}
-function publishChekListUncompleted(userId,doc,fieldNames,modifier){
+function publishChekListUncompleted(userId, doc, fieldNames, modifier){
const card = Cards.findOne(doc.cardId);
const boardId = card.boardId;
const checklistId = doc.checklistId;
const checkList = Checklists.findOne({_id:checklistId});
if(checkList.isFinished()){
- let act = {
+ const act = {
userId,
- activityType: "checklistUncompleted",
+ activityType: 'checklistUncompleted',
cardId: doc.cardId,
boardId,
checklistId: doc.checklistId,
- checklistName:doc.title
- }
+ checklistName:doc.title,
+ };
Activities.insert(act);
}
}
@@ -161,16 +161,15 @@ if (Meteor.isServer) {
});
ChecklistItems.after.update((userId, doc, fieldNames, modifier) => {
- publishCheckActivity(userId,doc);
- publishChekListCompleted(userId,doc,fieldNames,modifier)
+ publishCheckActivity(userId, doc);
+ publishChekListCompleted(userId, doc, fieldNames, modifier);
});
ChecklistItems.before.update((userId, doc, fieldNames, modifier) => {
- publishChekListUncompleted(userId,doc,fieldNames,modifier)
+ publishChekListUncompleted(userId, doc, fieldNames, modifier);
});
-
ChecklistItems.after.insert((userId, doc) => {
itemCreation(userId, doc);
});
diff --git a/models/checklists.js b/models/checklists.js
index 26429092..425a10b2 100644
--- a/models/checklists.js
+++ b/models/checklists.js
@@ -103,7 +103,7 @@ if (Meteor.isServer) {
cardId: doc.cardId,
boardId: Cards.findOne(doc.cardId).boardId,
checklistId: doc._id,
- checklistName:doc.title
+ checklistName:doc.title,
});
});
@@ -120,7 +120,7 @@ if (Meteor.isServer) {
cardId: doc.cardId,
boardId: Cards.findOne(doc.cardId).boardId,
checklistId: doc._id,
- checklistName:doc.title
+ checklistName:doc.title,
});
diff --git a/models/export.js b/models/export.js
index c65ebf52..0911a631 100644
--- a/models/export.js
+++ b/models/export.js
@@ -31,7 +31,7 @@ if (Meteor.isServer) {
if (exporter.canExport(user)) {
JsonRoutes.sendResult(res, {
code: 200,
- data: exporter.build()
+ data: exporter.build(),
});
} else {
// we could send an explicit error message, but on the other hand the only
@@ -52,16 +52,16 @@ class Exporter {
// we do not want to retrieve boardId in related elements
const noBoardId = {
fields: {
- boardId: 0
- }
+ boardId: 0,
+ },
};
const result = {
_format: 'wekan-board-1.0.0',
};
_.extend(result, Boards.findOne(this._boardId, {
fields: {
- stars: 0
- }
+ stars: 0,
+ },
}));
result.lists = Lists.find(byBoard, noBoardId).fetch();
result.cards = Cards.find(byBoardNoLinked, noBoardId).fetch();
@@ -77,21 +77,21 @@ class Exporter {
result.actions = [];
result.cards.forEach((card) => {
result.checklists.push(...Checklists.find({
- cardId: card._id
+ cardId: card._id,
}).fetch());
result.checklistItems.push(...ChecklistItems.find({
- cardId: card._id
+ cardId: card._id,
}).fetch());
result.subtaskItems.push(...Cards.find({
- parentid: card._id
+ parentid: card._id,
}).fetch());
});
result.rules.forEach((rule) => {
result.triggers.push(...Triggers.find({
- _id: rule.triggerId
+ _id: rule.triggerId,
}, noBoardId).fetch());
result.actions.push(...Actions.find({
- _id: rule.actionId
+ _id: rule.actionId,
}, noBoardId).fetch());
});
@@ -154,8 +154,8 @@ class Exporter {
});
const byUserIds = {
_id: {
- $in: Object.getOwnPropertyNames(users)
- }
+ $in: Object.getOwnPropertyNames(users),
+ },
};
// we use whitelist to be sure we do not expose inadvertently
// some secret fields that gets added to User later.
diff --git a/models/rules.js b/models/rules.js
index fe6b04cb..7d971980 100644
--- a/models/rules.js
+++ b/models/rules.js
@@ -31,11 +31,10 @@ Rules.helpers({
},
getTrigger(){
return Triggers.findOne({_id:this.triggerId});
- }
+ },
});
-
Rules.allow({
insert(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
@@ -45,5 +44,5 @@ Rules.allow({
},
remove(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
- }
+ },
});
diff --git a/models/triggers.js b/models/triggers.js
index c8e4cc75..15982b6e 100644
--- a/models/triggers.js
+++ b/models/triggers.js
@@ -4,8 +4,8 @@ Triggers.mutations({
rename(description) {
return {
$set: {
- description
- }
+ description,
+ },
};
},
});
@@ -19,7 +19,7 @@ Triggers.allow({
},
remove(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
- }
+ },
});
Triggers.helpers({
@@ -30,7 +30,7 @@ Triggers.helpers({
getRule() {
return Rules.findOne({
- triggerId: this._id
+ triggerId: this._id,
});
},
@@ -44,7 +44,7 @@ Triggers.helpers({
findList(title) {
return Lists.findOne({
- title: title
+ title,
});
},
@@ -54,5 +54,5 @@ Triggers.helpers({
return _.contains(this.labelIds, label._id);
});
return cardLabels;
- }
-}); \ No newline at end of file
+ },
+});
diff --git a/models/wekanCreator.js b/models/wekanCreator.js
index 6841a6ae..b018b06d 100644
--- a/models/wekanCreator.js
+++ b/models/wekanCreator.js
@@ -224,8 +224,8 @@ export class WekanCreator {
const boardId = Boards.direct.insert(boardToCreate);
Boards.direct.update(boardId, {
$set: {
- modifiedAt: this._now()
- }
+ modifiedAt: this._now(),
+ },
});
// log activity
Activities.direct.insert({
@@ -373,15 +373,15 @@ export class WekanCreator {
if (wekanCoverId === att._id) {
Cards.direct.update(cardId, {
$set: {
- coverId: wekanAtt._id
- }
+ coverId: wekanAtt._id,
+ },
});
}
}
});
} else if (att.file) {
file.attachData(new Buffer(att.file, 'base64'), {
- type: att.type
+ type: att.type,
}, (error) => {
file.name(att.name);
file.boardId = boardId;
@@ -401,8 +401,8 @@ export class WekanCreator {
if (wekanCoverId === att._id) {
Cards.direct.update(cardId, {
$set: {
- coverId: wekanAtt._id
- }
+ coverId: wekanAtt._id,
+ },
});
}
}
@@ -448,8 +448,8 @@ export class WekanCreator {
const listId = Lists.direct.insert(listToCreate);
Lists.direct.update(listId, {
$set: {
- 'updatedAt': this._now()
- }
+ 'updatedAt': this._now(),
+ },
});
this.lists[list._id] = listId;
// // log activity
@@ -485,8 +485,8 @@ export class WekanCreator {
const swimlaneId = Swimlanes.direct.insert(swimlaneToCreate);
Swimlanes.direct.update(swimlaneId, {
$set: {
- 'updatedAt': this._now()
- }
+ 'updatedAt': this._now(),
+ },
});
this.swimlanes[swimlane._id] = swimlaneId;
});
@@ -512,13 +512,13 @@ export class WekanCreator {
createTriggers(wekanTriggers, boardId) {
wekanTriggers.forEach((trigger, ruleIndex) => {
if (trigger.hasOwnProperty('labelId')) {
- trigger['labelId'] = this.labels[trigger['labelId']]
+ trigger.labelId = this.labels[trigger.labelId];
}
if (trigger.hasOwnProperty('memberId')) {
- trigger['memberId'] = this.members[trigger['memberId']]
+ trigger.memberId = this.members[trigger.memberId];
}
- trigger['boardId'] = boardId;
- const oldId = trigger['_id'];
+ trigger.boardId = boardId;
+ const oldId = trigger._id;
delete trigger._id;
this.triggers[oldId] = Triggers.direct.insert(trigger);
});
@@ -527,13 +527,13 @@ export class WekanCreator {
createActions(wekanActions, boardId) {
wekanActions.forEach((action, ruleIndex) => {
if (action.hasOwnProperty('labelId')) {
- action['labelId'] = this.labels[action['labelId']]
+ action.labelId = this.labels[action.labelId];
}
if (action.hasOwnProperty('memberId')) {
- action['memberId'] = this.members[action['memberId']]
+ action.memberId = this.members[action.memberId];
}
- action['boardId'] = boardId;
- const oldId = action['_id'];
+ action.boardId = boardId;
+ const oldId = action._id;
delete action._id;
this.actions[oldId] = Actions.direct.insert(action);
});
@@ -542,9 +542,9 @@ export class WekanCreator {
createRules(wekanRules, boardId) {
wekanRules.forEach((rule, ruleIndex) => {
// Create the rule
- rule['boardId'] = boardId;
- rule['triggerId'] = this.triggers[rule['triggerId']];
- rule['actionId'] = this.actions[rule['actionId']];
+ rule.boardId = boardId;
+ rule.triggerId = this.triggers[rule.triggerId];
+ rule.actionId = this.actions[rule.actionId];
delete rule._id;
Rules.direct.insert(rule);
});
@@ -568,64 +568,64 @@ export class WekanCreator {
parseActivities(wekanBoard) {
wekanBoard.activities.forEach((activity) => {
switch (activity.activityType) {
- case 'addAttachment':
- {
- // We have to be cautious, because the attachment could have been removed later.
- // In that case Wekan still reports its addition, but removes its 'url' field.
- // So we test for that
- const wekanAttachment = wekanBoard.attachments.filter((attachment) => {
- return attachment._id === activity.attachmentId;
- })[0];
+ case 'addAttachment':
+ {
+ // We have to be cautious, because the attachment could have been removed later.
+ // In that case Wekan still reports its addition, but removes its 'url' field.
+ // So we test for that
+ const wekanAttachment = wekanBoard.attachments.filter((attachment) => {
+ return attachment._id === activity.attachmentId;
+ })[0];
- if (typeof wekanAttachment !== 'undefined' && wekanAttachment) {
- if (wekanAttachment.url || wekanAttachment.file) {
- // we cannot actually create the Wekan attachment, because we don't yet
- // have the cards to attach it to, so we store it in the instance variable.
- const wekanCardId = activity.cardId;
- if (!this.attachments[wekanCardId]) {
- this.attachments[wekanCardId] = [];
- }
- this.attachments[wekanCardId].push(wekanAttachment);
- }
+ if (typeof wekanAttachment !== 'undefined' && wekanAttachment) {
+ if (wekanAttachment.url || wekanAttachment.file) {
+ // we cannot actually create the Wekan attachment, because we don't yet
+ // have the cards to attach it to, so we store it in the instance variable.
+ const wekanCardId = activity.cardId;
+ if (!this.attachments[wekanCardId]) {
+ this.attachments[wekanCardId] = [];
}
- break;
- }
- case 'addComment':
- {
- const wekanComment = wekanBoard.comments.filter((comment) => {
- return comment._id === activity.commentId;
- })[0];
- const id = activity.cardId;
- if (!this.comments[id]) {
- this.comments[id] = [];
- }
- this.comments[id].push(wekanComment);
- break;
- }
- case 'createBoard':
- {
- this.createdAt.board = activity.createdAt;
- break;
- }
- case 'createCard':
- {
- const cardId = activity.cardId;
- this.createdAt.cards[cardId] = activity.createdAt;
- this.createdBy.cards[cardId] = activity.userId;
- break;
- }
- case 'createList':
- {
- const listId = activity.listId;
- this.createdAt.lists[listId] = activity.createdAt;
- break;
- }
- case 'createSwimlane':
- {
- const swimlaneId = activity.swimlaneId;
- this.createdAt.swimlanes[swimlaneId] = activity.createdAt;
- break;
+ this.attachments[wekanCardId].push(wekanAttachment);
}
+ }
+ break;
+ }
+ case 'addComment':
+ {
+ const wekanComment = wekanBoard.comments.filter((comment) => {
+ return comment._id === activity.commentId;
+ })[0];
+ const id = activity.cardId;
+ if (!this.comments[id]) {
+ this.comments[id] = [];
+ }
+ this.comments[id].push(wekanComment);
+ break;
+ }
+ case 'createBoard':
+ {
+ this.createdAt.board = activity.createdAt;
+ break;
+ }
+ case 'createCard':
+ {
+ const cardId = activity.cardId;
+ this.createdAt.cards[cardId] = activity.createdAt;
+ this.createdBy.cards[cardId] = activity.userId;
+ break;
+ }
+ case 'createList':
+ {
+ const listId = activity.listId;
+ this.createdAt.lists[listId] = activity.createdAt;
+ break;
+ }
+ case 'createSwimlane':
+ {
+ const swimlaneId = activity.swimlaneId;
+ this.createdAt.swimlanes[swimlaneId] = activity.createdAt;
+ break;
+ }
}
});
}
@@ -633,116 +633,116 @@ export class WekanCreator {
importActivities(activities, boardId) {
activities.forEach((activity) => {
switch (activity.activityType) {
- // Board related activities
- // TODO: addBoardMember, removeBoardMember
- case 'createBoard':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- type: 'board',
- activityTypeId: boardId,
- activityType: activity.activityType,
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- // List related activities
- // TODO: removeList, archivedList
- case 'createList':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- type: 'list',
- activityType: activity.activityType,
- listId: this.lists[activity.listId],
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- // Card related activities
- // TODO: archivedCard, restoredCard, joinMember, unjoinMember
- case 'createCard':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- activityType: activity.activityType,
- listId: this.lists[activity.listId],
- cardId: this.cards[activity.cardId],
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- case 'moveCard':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- oldListId: this.lists[activity.oldListId],
- activityType: activity.activityType,
- listId: this.lists[activity.listId],
- cardId: this.cards[activity.cardId],
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- // Comment related activities
- case 'addComment':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- activityType: activity.activityType,
- cardId: this.cards[activity.cardId],
- commentId: this.commentIds[activity.commentId],
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- // Attachment related activities
- case 'addAttachment':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- type: 'card',
- activityType: activity.activityType,
- attachmentId: this.attachmentIds[activity.attachmentId],
- cardId: this.cards[activity.cardId],
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- // Checklist related activities
- case 'addChecklist':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- activityType: activity.activityType,
- cardId: this.cards[activity.cardId],
- checklistId: this.checklists[activity.checklistId],
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
- case 'addChecklistItem':
- {
- Activities.direct.insert({
- userId: this._user(activity.userId),
- activityType: activity.activityType,
- cardId: this.cards[activity.cardId],
- checklistId: this.checklists[activity.checklistId],
- checklistItemId: activity.checklistItemId.replace(
- activity.checklistId,
- this.checklists[activity.checklistId]),
- boardId,
- createdAt: this._now(activity.createdAt),
- });
- break;
- }
+ // Board related activities
+ // TODO: addBoardMember, removeBoardMember
+ case 'createBoard':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ type: 'board',
+ activityTypeId: boardId,
+ activityType: activity.activityType,
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ // List related activities
+ // TODO: removeList, archivedList
+ case 'createList':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ type: 'list',
+ activityType: activity.activityType,
+ listId: this.lists[activity.listId],
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ // Card related activities
+ // TODO: archivedCard, restoredCard, joinMember, unjoinMember
+ case 'createCard':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ activityType: activity.activityType,
+ listId: this.lists[activity.listId],
+ cardId: this.cards[activity.cardId],
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ case 'moveCard':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ oldListId: this.lists[activity.oldListId],
+ activityType: activity.activityType,
+ listId: this.lists[activity.listId],
+ cardId: this.cards[activity.cardId],
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ // Comment related activities
+ case 'addComment':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ activityType: activity.activityType,
+ cardId: this.cards[activity.cardId],
+ commentId: this.commentIds[activity.commentId],
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ // Attachment related activities
+ case 'addAttachment':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ type: 'card',
+ activityType: activity.activityType,
+ attachmentId: this.attachmentIds[activity.attachmentId],
+ cardId: this.cards[activity.cardId],
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ // Checklist related activities
+ case 'addChecklist':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ activityType: activity.activityType,
+ cardId: this.cards[activity.cardId],
+ checklistId: this.checklists[activity.checklistId],
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
+ case 'addChecklistItem':
+ {
+ Activities.direct.insert({
+ userId: this._user(activity.userId),
+ activityType: activity.activityType,
+ cardId: this.cards[activity.cardId],
+ checklistId: this.checklists[activity.checklistId],
+ checklistItemId: activity.checklistItemId.replace(
+ activity.checklistId,
+ this.checklists[activity.checklistId]),
+ boardId,
+ createdAt: this._now(activity.createdAt),
+ });
+ break;
+ }
}
});
}
@@ -790,4 +790,4 @@ export class WekanCreator {
// XXX add members
return boardId;
}
-} \ No newline at end of file
+}