diff options
author | boeserwolf <github@noxware.de> | 2020-04-19 15:53:13 +0300 |
---|---|---|
committer | boeserwolf <github@noxware.de> | 2020-04-19 15:53:13 +0300 |
commit | b42d8346cda99258f4ab5689ebd02fdc7c2e85c3 (patch) | |
tree | 327c5b8df61736328b48bc8de64aa6fcfd7057c0 /models | |
parent | 1a065ff351b5c37536d73cc3d46b736fe310e32c (diff) | |
download | wekan-b42d8346cda99258f4ab5689ebd02fdc7c2e85c3.tar.gz wekan-b42d8346cda99258f4ab5689ebd02fdc7c2e85c3.tar.bz2 wekan-b42d8346cda99258f4ab5689ebd02fdc7c2e85c3.zip |
Insert new boards at last position
Diffstat (limited to 'models')
-rw-r--r-- | models/boards.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index 4c2d96da..170ebc5a 100644 --- a/models/boards.js +++ b/models/boards.js @@ -1295,6 +1295,14 @@ if (Meteor.isServer) { }); } +// Insert new board at last position in sort order. +Boards.before.insert((userId, doc) => { + const lastBoard = Boards.findOne({ sort: { $exists: true } }, { sort: { sort: -1 } }); + if (lastBoard && typeof lastBoard.sort !== 'undefined') { + doc.sort = lastBoard.sort + 1; + } +}); + if (Meteor.isServer) { // Let MongoDB ensure that a member is not included twice in the same board Meteor.startup(() => { |