From 9de704040172e37769fa28cf571f293dfbd8bbb5 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Mon, 15 May 2023 23:43:42 +0300 Subject: [PATCH] Moved new_checklist_item API to correct file where is other checklist item API. Thanks to xet7 ! --- models/checklistItems.js | 45 ++++++++++++++++++++++++++++++++++++++++ models/checklists.js | 45 ---------------------------------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/models/checklistItems.js b/models/checklistItems.js index a93b75a8d..c9749d23b 100644 --- a/models/checklistItems.js +++ b/models/checklistItems.js @@ -282,6 +282,51 @@ if (Meteor.isServer) { }, ); + /** + * @operation new_checklist_item + * @summary add a new item to a checklist + * + * @param {string} boardId the board ID + * @param {string} cardId the card ID + * @param {string} checklistId the ID of the checklist + * @param {string} title the title of the new item + * @return_type {_id: string} + */ + + JsonRoutes.add( + 'POST', + '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items', + function(req, res) { + const paramBoardId = req.params.boardId; + const paramChecklistId = req.params.checklistId; + const paramCardId = req.params.cardId; + Authentication.checkBoardAccess(req.userId, paramBoardId); + const checklist = Checklists.findOne({ + _id: paramChecklistId, + cardId: paramCardId, + }); + if (checklist) { + const id = ChecklistItems.insert({ + cardId: paramCardId, + checklistId: paramChecklistId, + title: req.body.title, + isFinished: false, + sort: 0, + }); + JsonRoutes.sendResult(res, { + code: 200, + data: { + _id: id, + }, + }); + } else { + JsonRoutes.sendResult(res, { + code: 404, + }); + } + }, + ); + /** * @operation edit_checklist_item * @tag Checklists diff --git a/models/checklists.js b/models/checklists.js index cd8d3fb80..302becdb9 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -383,51 +383,6 @@ if (Meteor.isServer) { }, ); - /** - * @operation new_checklist_item - * @summary add a new item to a checklist - * - * @param {string} boardId the board ID - * @param {string} cardId the card ID - * @param {string} checklistId the ID of the checklist - * @param {string} title the title of the new item - * @return_type {_id: string} - */ - - JsonRoutes.add( - 'POST', - '/api/boards/:boardId/cards/:cardId/checklists/:checklistId/items', - function(req, res) { - const paramBoardId = req.params.boardId; - const paramChecklistId = req.params.checklistId; - const paramCardId = req.params.cardId; - Authentication.checkBoardAccess(req.userId, paramBoardId); - const checklist = Checklists.findOne({ - _id: paramChecklistId, - cardId: paramCardId, - }); - if (checklist) { - const id = ChecklistItems.insert({ - cardId: paramCardId, - checklistId: paramChecklistId, - title: req.body.title, - isFinished: false, - sort: 0, - }); - JsonRoutes.sendResult(res, { - code: 200, - data: { - _id: id, - }, - }); - } else { - JsonRoutes.sendResult(res, { - code: 404, - }); - } - }, - ); - /** * @operation delete_checklist * @summary Delete a checklist