diff options
Diffstat (limited to 'models/boards.js')
-rw-r--r-- | models/boards.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index b5f8b01b..857aa963 100644 --- a/models/boards.js +++ b/models/boards.js @@ -55,6 +55,8 @@ Boards.attachSchema( autoValue() { if (this.isInsert) { return new Date(); + } else if (this.isUpsert) { + return { $setOnInsert: new Date() }; } else { this.unset(); } @@ -407,6 +409,27 @@ Boards.helpers({ }, lists() { + //currentUser = Meteor.user(); + //if (currentUser) { + // enabled = Meteor.user().hasSortBy(); + //} + //return enabled ? this.newestLists() : this.draggableLists(); + return this.draggableLists(); + }, + + newestLists() { + // sorted lists from newest to the oldest, by its creation date or its cards' last modification date + const value = Meteor.user()._getListSortBy(); + const sortKey = { starred: -1, [value[0]]: value[1] }; // [["starred",-1],value]; + return Lists.find( + { + boardId: this._id, + archived: false, + }, + { sort: sortKey }, + ); + }, + draggableLists() { return Lists.find({ boardId: this._id }, { sort: { sort: 1 } }); }, @@ -697,6 +720,13 @@ Boards.helpers({ return result; }, + cardsDueInBetween(start, end) { + return Cards.find({ + boardId: this._id, + dueAt: { $gte: start, $lte: end }, + }); + }, + cardsInInterval(start, end) { return Cards.find({ boardId: this._id, |