summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/boards.js15
-rw-r--r--models/cards.js17
-rw-r--r--models/swimlanes.js15
3 files changed, 47 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js
index a9348478..c7f93022 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -409,6 +409,21 @@ Boards.helpers({
},
lists() {
+ const enabled = Meteor.user().hasShowDesktopDragHandles();
+ return enabled ? this.draggableLists() : this.newestLists();
+ },
+
+ newestLists() {
+ // sorted lists from newest to the oldest, by its creation date or its cards' last modification date
+ return Lists.find(
+ {
+ boardId: this._id,
+ archived: false,
+ },
+ { sort: { updatedAt: -1 } },
+ );
+ },
+ draggableLists() {
return Lists.find({ boardId: this._id }, { sort: { sort: 1 } });
},
diff --git a/models/cards.js b/models/cards.js
index 371ad185..35d596d6 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -1695,6 +1695,23 @@ if (Meteor.isServer) {
const oldvalue = doc[action] || '';
const activityType = `a-${action}`;
const card = Cards.findOne(doc._id);
+ const list = card.list();
+ if (list) {
+ // change list modifiedAt
+ const modifiedAt = new Date();
+ const boardId = list.boardId;
+ Lists.direct.update(
+ {
+ _id: list._id,
+ },
+ {
+ $set: {
+ modifiedAt,
+ boardId,
+ },
+ },
+ );
+ }
const username = Users.findOne(userId).username;
const activity = {
userId,
diff --git a/models/swimlanes.js b/models/swimlanes.js
index 46e410da..4cd35574 100644
--- a/models/swimlanes.js
+++ b/models/swimlanes.js
@@ -174,6 +174,21 @@ Swimlanes.helpers({
},
lists() {
+ const enabled = Meteor.user().hasShowDesktopDragHandles();
+ return enabled ? this.draggableLists() : this.newestLists();
+ },
+ newestLists() {
+ // sorted lists from newest to the oldest, by its creation date or its cards' last modification date
+ return Lists.find(
+ {
+ boardId: this.boardId,
+ swimlaneId: { $in: [this._id, ''] },
+ archived: false,
+ },
+ { sort: { updatedAt: -1 } },
+ );
+ },
+ draggableLists() {
return Lists.find(
{
boardId: this.boardId,