瀏覽代碼

api: fix the sort field when inserting a swimlane or a list

This has the side effect of always inserting the element at the end.
Benjamin Tissoires 6 年之前
父節點
當前提交
b5411841cf
共有 2 個文件被更改,包括 4 次插入0 次删除
  1. 2 0
      models/lists.js
  2. 2 0
      models/swimlanes.js

+ 2 - 0
models/lists.js

@@ -314,9 +314,11 @@ if (Meteor.isServer) {
     try {
       Authentication.checkUserId( req.userId);
       const paramBoardId = req.params.boardId;
+      const board = Boards.findOne(paramBoardId);
       const id = Lists.insert({
         title: req.body.title,
         boardId: paramBoardId,
+        sort: board.lists().count(),
       });
       JsonRoutes.sendResult(res, {
         code: 200,

+ 2 - 0
models/swimlanes.js

@@ -256,9 +256,11 @@ if (Meteor.isServer) {
     try {
       Authentication.checkUserId( req.userId);
       const paramBoardId = req.params.boardId;
+      const board = Boards.findOne(paramBoardId);
       const id = Swimlanes.insert({
         title: req.body.title,
         boardId: paramBoardId,
+        sort: board.swimlanes().count(),
       });
       JsonRoutes.sendResult(res, {
         code: 200,