Pārlūkot izejas kodu

api: new_card: add the card at the end of the list

If we keep the `0` value, the card might be inserted in the middle of the
list, making it hard to find it later on.

Always append the card at the end of the list by setting a sort value
based on the number of cards in the list.
Benjamin Tissoires 6 gadi atpakaļ
vecāks
revīzija
6c3dbc3c6f
1 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 5 1
      models/cards.js

+ 5 - 1
models/cards.js

@@ -1526,6 +1526,10 @@ if (Meteor.isServer) {
     Authentication.checkUserId(req.userId);
     Authentication.checkUserId(req.userId);
     const paramBoardId = req.params.boardId;
     const paramBoardId = req.params.boardId;
     const paramListId = req.params.listId;
     const paramListId = req.params.listId;
+    const currentCards = Cards.find({
+      listId: paramListId,
+      archived: false,
+    }, { sort: ['sort'] });
     const check = Users.findOne({
     const check = Users.findOne({
       _id: req.body.authorId,
       _id: req.body.authorId,
     });
     });
@@ -1538,7 +1542,7 @@ if (Meteor.isServer) {
         description: req.body.description,
         description: req.body.description,
         userId: req.body.authorId,
         userId: req.body.authorId,
         swimlaneId: req.body.swimlaneId,
         swimlaneId: req.body.swimlaneId,
-        sort: 0,
+        sort: currentCards.count(),
         members,
         members,
       });
       });
       JsonRoutes.sendResult(res, {
       JsonRoutes.sendResult(res, {