diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/activities.js | 1 | ||||
-rw-r--r-- | models/announcements.js | 36 | ||||
-rw-r--r-- | models/cardComments.js | 6 | ||||
-rw-r--r-- | models/trelloCreator.js | 45 |
4 files changed, 63 insertions, 25 deletions
diff --git a/models/activities.js b/models/activities.js index 4ddcfa72..be290dce 100644 --- a/models/activities.js +++ b/models/activities.js @@ -110,6 +110,7 @@ if (Meteor.isServer) { if (activity.commentId) { const comment = activity.comment(); params.comment = comment.text; + params.commentId = comment._id; } if (activity.attachmentId) { const attachment = activity.attachment(); diff --git a/models/announcements.js b/models/announcements.js new file mode 100644 index 00000000..2cb1e1b7 --- /dev/null +++ b/models/announcements.js @@ -0,0 +1,36 @@ +Announcements = new Mongo.Collection('announcements'); + +Announcements.attachSchema(new SimpleSchema({ + enabled: { + type: Boolean, + defaultValue: false, + }, + title: { + type: String, + optional: true, + }, + body: { + type: String, + optional: true, + }, + sort: { + type: Number, + decimal: true, + }, +})); + +Announcements.allow({ + update(userId) { + const user = Users.findOne(userId); + return user && user.isAdmin; + }, +}); + +if (Meteor.isServer) { + Meteor.startup(() => { + const announcements = Announcements.findOne({}); + if(!announcements){ + Announcements.insert({enabled: false, sort: 0}); + } + }); +} diff --git a/models/cardComments.js b/models/cardComments.js index 352030f1..cc1c55bc 100644 --- a/models/cardComments.js +++ b/models/cardComments.js @@ -125,15 +125,15 @@ if (Meteor.isServer) { boardId: paramBoardId, }); - const cardComment = CardComments.findOne({_id: id, cardId:paramCardId, boardId: paramBoardId }); - commentCreation(req.body.authorId, cardComment); - JsonRoutes.sendResult(res, { code: 200, data: { _id: id, }, }); + + const cardComment = CardComments.findOne({_id: id, cardId:paramCardId, boardId: paramBoardId }); + commentCreation(req.body.authorId, cardComment); }); JsonRoutes.add('DELETE', '/api/boards/:boardId/cards/:cardId/comments/:commentId', function (req, res, next) { diff --git a/models/trelloCreator.js b/models/trelloCreator.js index e7f98e85..0f801ea3 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -113,7 +113,6 @@ export class TrelloCreator { check(trelloLabels, [Match.ObjectIncluding({ // XXX refine control by validating 'color' against a list of allowed // values (is it worth the maintenance?) - color: String, name: String, })]); } @@ -184,7 +183,7 @@ export class TrelloCreator { trelloBoard.labels.forEach((label) => { const labelToCreate = { _id: Random.id(6), - color: label.color, + color: label.color ? label.color : 'black', name: label.name, }; // We need to remember them by Trello ID, as this is the only ref we have @@ -398,27 +397,29 @@ export class TrelloCreator { createChecklists(trelloChecklists) { trelloChecklists.forEach((checklist) => { - // Create the checklist - const checklistToCreate = { - cardId: this.cards[checklist.idCard], - title: checklist.name, - createdAt: this._now(), - sort: checklist.pos, - }; - const checklistId = Checklists.direct.insert(checklistToCreate); - // keep track of Trello id => WeKan id - this.checklists[checklist.id] = checklistId; - // 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', - sort: item.pos, + if (this.cards[checklist.idCard]) { + // Create the checklist + const checklistToCreate = { + cardId: this.cards[checklist.idCard], + title: checklist.name, + createdAt: this._now(), + sort: checklist.pos, + }; + const checklistId = Checklists.direct.insert(checklistToCreate); + // keep track of Trello id => WeKan id + this.checklists[checklist.id] = checklistId; + // 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', + sort: item.pos, + }); }); - }); - Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}}); + Checklists.direct.update(checklistId, {$set: {items: itemsToCreate}}); + } }); } |