From f8ef2e33de2dc27b72e6de3eb87eb7b7e9678142 Mon Sep 17 00:00:00 2001 From: Mirko Genovese Date: Thu, 22 Feb 2024 07:50:21 +0100 Subject: [PATCH] cards.js Added a control to check error if card is not updated --- models/cards.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/models/cards.js b/models/cards.js index 4f059ac9b..c4074a32b 100644 --- a/models/cards.js +++ b/models/cards.js @@ -3504,6 +3504,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( const newBoardId = req.body.newBoardId; const newSwimlaneId = req.body.newSwimlaneId; const newListId = req.body.newListId; + let updated = false; Authentication.checkBoardAccess(req.userId, paramBoardId); if (req.body.title) { @@ -3521,6 +3522,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; } if (req.body.sort) { const newSort = req.body.sort; @@ -3537,6 +3539,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; } if (req.body.parentId) { const newParentId = req.body.parentId; @@ -3553,6 +3556,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; } if (req.body.description) { const newDescription = req.body.description; @@ -3569,6 +3573,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; } if (req.body.color) { const newColor = req.body.color; @@ -3581,6 +3586,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { color: newColor } }, ); + updated = true; } if (req.body.vote) { const newVote = req.body.vote; @@ -3599,6 +3605,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { vote: newVote } }, ); + updated = true; } if (req.body.poker) { const newPoker = req.body.poker; @@ -3624,6 +3631,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { poker: newPoker } }, ); + updated = true; } if (req.body.labelIds) { let newlabelIds = req.body.labelIds; @@ -3647,6 +3655,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; } if (req.body.requestedBy) { const newrequestedBy = req.body.requestedBy; @@ -3659,6 +3668,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { requestedBy: newrequestedBy } }, ); + updated = true; } if (req.body.assignedBy) { const newassignedBy = req.body.assignedBy; @@ -3671,6 +3681,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { assignedBy: newassignedBy } }, ); + updated = true; } if (req.body.receivedAt) { const newreceivedAt = req.body.receivedAt; @@ -3683,6 +3694,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { receivedAt: newreceivedAt } }, ); + updated = true; } if (req.body.startAt) { const newstartAt = req.body.startAt; @@ -3695,6 +3707,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { startAt: newstartAt } }, ); + updated = true; } if (req.body.dueAt) { const newdueAt = req.body.dueAt; @@ -3707,6 +3720,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { dueAt: newdueAt } }, ); + updated = true; } if (req.body.endAt) { const newendAt = req.body.endAt; @@ -3719,6 +3733,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { endAt: newendAt } }, ); + updated = true; } if (req.body.spentTime) { const newspentTime = req.body.spentTime; @@ -3731,6 +3746,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { spentTime: newspentTime } }, ); + updated = true; } if (req.body.isOverTime) { const newisOverTime = req.body.isOverTime; @@ -3743,6 +3759,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { isOverTime: newisOverTime } }, ); + updated = true; } if (req.body.customFields) { const newcustomFields = req.body.customFields; @@ -3755,6 +3772,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { customFields: newcustomFields } }, ); + updated = true; } if (req.body.members) { let newmembers = req.body.members; @@ -3774,6 +3792,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { members: newmembers } }, ); + updated = true; } if (req.body.assignees) { let newassignees = req.body.assignees; @@ -3793,6 +3812,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { assignees: newassignees } }, ); + updated = true; } if (req.body.swimlaneId) { const newParamSwimlaneId = req.body.swimlaneId; @@ -3805,6 +3825,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, { $set: { swimlaneId: newParamSwimlaneId } }, ); + updated = true; } if (req.body.listId) { const newParamListId = req.body.listId; @@ -3821,6 +3842,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; const card = ReactiveCache.getCard(paramCardId); cardMove( @@ -3849,6 +3871,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; const card = ReactiveCache.getCard(paramCardId); cardMove( @@ -3878,7 +3901,18 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }, }, ); + updated = true; } + // Check if update is true or false + if (!updated) { + JsonRoutes.sendResult(res, { + code: 404, + data: { + message: 'Error', + }, + }); + return; + } JsonRoutes.sendResult(res, { code: 200, data: {