diff options
Diffstat (limited to 'models/boards.js')
-rw-r--r-- | models/boards.js | 77 |
1 files changed, 58 insertions, 19 deletions
diff --git a/models/boards.js b/models/boards.js index c77c9de2..641ecdb9 100644 --- a/models/boards.js +++ b/models/boards.js @@ -110,6 +110,7 @@ Boards.attachSchema(new SimpleSchema({ userId: this.userId, isAdmin: true, isActive: true, + isNoComments: false, isCommentOnly: false, }]; } @@ -124,6 +125,9 @@ Boards.attachSchema(new SimpleSchema({ 'members.$.isActive': { type: Boolean, }, + 'members.$.isNoComments': { + type: Boolean, + }, 'members.$.isCommentOnly': { type: Boolean, }, @@ -177,6 +181,28 @@ Boards.attachSchema(new SimpleSchema({ optional: true, defaultValue: 'no-parent', }, + startAt: { + type: Date, + optional: true, + }, + dueAt: { + type: Date, + optional: true, + }, + endAt: { + type: Date, + optional: true, + }, + spentTime: { + type: Number, + decimal: true, + optional: true, + }, + isOvertime: { + type: Boolean, + defaultValue: false, + optional: true, + }, })); @@ -212,6 +238,10 @@ Boards.helpers({ return this.permission === 'public'; }, + cards() { + return Cards.find({ boardId: this._id, archived: false }, { sort: { title: 1 } }); + }, + lists() { return Lists.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } }); }, @@ -220,10 +250,6 @@ Boards.helpers({ return Swimlanes.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } }); }, - cards() { - return Cards.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } }); - }, - hasOvertimeCards(){ const card = Cards.findOne({isOvertime: true, boardId: this._id, archived: false} ); return card !== undefined; @@ -274,6 +300,10 @@ Boards.helpers({ return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: true }); }, + hasNoComments(memberId) { + return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: false, isNoComments: true }); + }, + hasCommentOnly(memberId) { return !!_.findWhere(this.members, { userId: memberId, isActive: true, isAdmin: false, isCommentOnly: true }); }, @@ -298,22 +328,22 @@ Boards.helpers({ return _id; }, - searchCards(term) { + searchCards(term, excludeLinked) { check(term, Match.OneOf(String, null, undefined)); - let query = { boardId: this._id }; + const query = { boardId: this._id }; + if (excludeLinked) { + query.linkedId = null; + } const projection = { limit: 10, sort: { createdAt: -1 } }; if (term) { const regex = new RegExp(term, 'i'); - query = { - boardId: this._id, - $or: [ - { title: regex }, - { description: regex }, - ], - }; + query.$or = [ + { title: regex }, + { description: regex }, + ]; } return Cards.find(query, projection); @@ -376,6 +406,7 @@ Boards.helpers({ cardsInInterval(start, end) { return Cards.find({ + boardId: this._id, $or: [ { startAt: { @@ -482,6 +513,7 @@ Boards.mutations({ userId: memberId, isAdmin: false, isActive: true, + isNoComments: false, isCommentOnly: false, }, }, @@ -509,7 +541,7 @@ Boards.mutations({ }; }, - setMemberPermission(memberId, isAdmin, isCommentOnly) { + setMemberPermission(memberId, isAdmin, isNoComments, isCommentOnly) { const memberIndex = this.memberIndex(memberId); // do not allow change permission of self @@ -520,6 +552,7 @@ Boards.mutations({ return { $set: { [`members.${memberIndex}.isAdmin`]: isAdmin, + [`members.${memberIndex}.isNoComments`]: isNoComments, [`members.${memberIndex}.isCommentOnly`]: isCommentOnly, }, }; @@ -817,18 +850,24 @@ if (Meteor.isServer) { members: [ { userId: req.body.owner, - isAdmin: true, - isActive: true, - isCommentOnly: false, + isAdmin: req.body.isAdmin || true, + isActive: req.body.isActive || true, + isNoComments: req.body.isNoComments || false, + isCommentOnly: req.body.isCommentOnly || false, }, ], - permission: 'public', - color: 'belize', + permission: req.body.permission || 'private', + color: req.body.color || 'belize', + }); + const swimlaneId = Swimlanes.insert({ + title: TAPi18n.__('default'), + boardId: id, }); JsonRoutes.sendResult(res, { code: 200, data: { _id: id, + defaultSwimlaneId: swimlaneId, }, }); } |