From 95522ebcd9100340a8d56a77103ec163185f6d05 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 21 Jul 2020 17:36:46 +0200 Subject: changed edit_card and get_card_by_customfields There was a bug in edit_card API: If I call API to edit listid and some fields It modifies only the listid. In addiction I've modified get_card_by_customfield to return full documents. --- models/cards.js | 66 +++++++++++++++++++++++++-------------------------------- models/users.js | 6 +++--- 2 files changed, 32 insertions(+), 40 deletions(-) diff --git a/models/cards.js b/models/cards.js index 2fd52827..04d187b3 100644 --- a/models/cards.js +++ b/models/cards.js @@ -2420,34 +2420,6 @@ if (Meteor.isServer) { }, ); } - if (req.body.hasOwnProperty('listId')) { - const newParamListId = req.body.listId; - Cards.direct.update( - { - _id: paramCardId, - listId: paramListId, - boardId: paramBoardId, - archived: false, - }, - { - $set: { - listId: newParamListId, - }, - }, - ); - - const card = Cards.findOne({ - _id: paramCardId, - }); - cardMove( - req.body.authorId, - card, - { - fieldName: 'listId', - }, - paramListId, - ); - } if (req.body.hasOwnProperty('parentId')) { const newParentId = req.body.parentId; Cards.direct.update( @@ -2691,6 +2663,34 @@ if (Meteor.isServer) { { $set: { swimlaneId: newParamSwimlaneId } }, ); } + if (req.body.hasOwnProperty('listId')) { + const newParamListId = req.body.listId; + Cards.direct.update( + { + _id: paramCardId, + listId: paramListId, + boardId: paramBoardId, + archived: false, + }, + { + $set: { + listId: newParamListId, + }, + }, + ); + + const card = Cards.findOne({ + _id: paramCardId, + }); + cardMove( + req.body.authorId, + card, + { + fieldName: 'listId', + }, + paramListId, + ); + } JsonRoutes.sendResult(res, { code: 200, data: { @@ -2772,15 +2772,7 @@ if (Meteor.isServer) { }, }, archived: false, - }).map(function(doc) { - return { - _id: doc._id, - title: doc.title, - description: doc.description, - listId: doc.listId, - swinlaneId: doc.swinlaneId, - }; - }), + }).fetch(), }); }, ); diff --git a/models/users.js b/models/users.js index 7c5d2855..0ff9d017 100644 --- a/models/users.js +++ b/models/users.js @@ -1136,9 +1136,9 @@ if (Meteor.isServer) { */ const Future = require('fibers/future'); - let future1 = new Future(); - let future2 = new Future(); - let future3 = new Future(); + const future1 = new Future(); + const future2 = new Future(); + const future3 = new Future(); Boards.insert( { title: TAPi18n.__('templates'), -- cgit v1.2.3-1-g7c22