summaryrefslogtreecommitdiffstats
path: root/models/boards.js
diff options
context:
space:
mode:
author蔡仲明 (Romulus Urakagi Tsai) <urakagi@gmail.com>2019-11-21 11:25:56 +0800
committerGitHub <noreply@github.com>2019-11-21 11:25:56 +0800
commit3e0bedd8c7a6dec97352212adb1cbde1ade44190 (patch)
tree651ff30d25ddb0416444370368d699e597c142d7 /models/boards.js
parent9bbeb73db1cd0ce1caaaca8dfb14ea92131bbf9d (diff)
parent4f5de87cc4c2281bd576548693de7c94e6a988c6 (diff)
downloadwekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.tar.gz
wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.tar.bz2
wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.zip
Merge pull request #1 from wekan/master
Update master
Diffstat (limited to 'models/boards.js')
-rw-r--r--models/boards.js30
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,