summaryrefslogtreecommitdiffstats
path: root/models/cardComments.js
diff options
context:
space:
mode:
authorhuneau romain <huneau.romain@gmail.com>2017-05-10 15:59:06 +0200
committerhuneau romain <huneau.romain@gmail.com>2017-05-10 15:59:06 +0200
commitd9c0825d5ff8cf3c6985545640148ce1c0f4262b (patch)
treeaf3a912993bcb0be609c1591aa2bd1b36b050d45 /models/cardComments.js
parent8267b5a01c1a8c2a00bb2464cb9860561985070d (diff)
downloadwekan-d9c0825d5ff8cf3c6985545640148ce1c0f4262b.tar.gz
wekan-d9c0825d5ff8cf3c6985545640148ce1c0f4262b.tar.bz2
wekan-d9c0825d5ff8cf3c6985545640148ce1c0f4262b.zip
add rest api for checklist and card comment
Diffstat (limited to 'models/cardComments.js')
-rw-r--r--models/cardComments.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/models/cardComments.js b/models/cardComments.js
index 070c148e..64af4433 100644
--- a/models/cardComments.js
+++ b/models/cardComments.js
@@ -80,3 +80,61 @@ if (Meteor.isServer) {
}
});
}
+
+//CARD COMMENT REST API
+if (Meteor.isServer) {
+ JsonRoutes.add('GET', '/api/boards/:boardId/cards/:cardId/comments', function (req, res, next) {
+ const paramBoardId = req.params.boardId;
+ const paramCardId = req.params.cardId;
+ JsonRoutes.sendResult(res, {
+ code: 200,
+ data: CardComments.find({ boardId: paramBoardId, cardId: paramCardId}).map(function (doc) {
+ return {
+ _id: doc._id,
+ comment: doc.text,
+ authorId: doc.userId,
+ };
+ }),
+ });
+ });
+
+ JsonRoutes.add('GET', '/api/boards/:boardId/cards/:cardId/comments/:commentId', function (req, res, next) {
+ const paramBoardId = req.params.boardId;
+ const paramCommentId = req.params.commentId;
+ const paramCardId = req.params.cardId;
+ JsonRoutes.sendResult(res, {
+ code: 200,
+ data: CardComments.findOne({ _id: paramCommentId, cardId: paramCardId, boardId: paramBoardId }),
+ });
+ });
+
+ JsonRoutes.add('POST', '/api/boards/:boardId/cards/:cardId/comments', function (req, res, next) {
+ const paramBoardId = req.params.boardId;
+ const paramCardId = req.params.cardId;
+ const id = CardComments.insert({
+ userId: req.body.authorId,
+ text: req.body.comment,
+ cardId: paramCardId,
+ boardId: paramBoardId,
+ });
+ JsonRoutes.sendResult(res, {
+ code: 200,
+ data: {
+ _id: id,
+ },
+ });
+ });
+
+ JsonRoutes.add('DELETE', '/api/boards/:boardId/cards/:cardId/comments/:commentId', function (req, res, next) {
+ const paramBoardId = req.params.boardId;
+ const paramCommentId = req.params.commentId;
+ const paramCardId = req.params.cardId;
+ CardComments.remove({ _id: paramCommentId, cardId: paramCardId, boardId: paramBoardId });
+ JsonRoutes.sendResult(res, {
+ code: 200,
+ data: {
+ _id: paramCardId,
+ },
+ });
+ });
+}