Update checklists.js

https://github.com/wekan/wekan/issues/4562
This commit is contained in:
DimDz 2023-05-02 15:08:14 +03:00 committed by GitHub
parent 2260f214ed
commit e9e3e14695
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -383,6 +383,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 delete_checklist
* @summary Delete a checklist