From 3a99eb9c9f708737c95202129c032ae12ea271e7 Mon Sep 17 00:00:00 2001 From: zago Date: Thu, 29 Jun 2017 12:24:33 +0200 Subject: adding a put method to update a card --- models/cards.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/models/cards.js b/models/cards.js index c48b4845..3eb4c69f 100644 --- a/models/cards.js +++ b/models/cards.js @@ -420,6 +420,36 @@ if (Meteor.isServer) { }); }); + JsonRoutes.add('PUT', '/api/boards/:boardId/lists/:listId/cards/:cardId', function (req, res, next) { + Authentication.checkUserId( req.userId); + const paramBoardId = req.params.boardId; + const paramCardId = req.params.cardId; + const paramListId = req.params.listId; + if(req.body.title !== undefined){ + const newTitle = req.body.title; + Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, + {$set:{title:newTitle}}); + } + if(req.body.listId !== undefined){ + const newParamListId = req.body.listId; + Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, + {$set:{listId:newParamListId}}); + } + if(req.body.description !== undefined){ + const newDescription = req.body.description; + Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, + {$set:{description:newDescription}}); + } + JsonRoutes.sendResult(res, { + code: 200, + data: { + _id: paramCardId, + }, + }); + }); + + + JsonRoutes.add('DELETE', '/api/boards/:boardId/lists/:listId/cards/:cardId', function (req, res, next) { Authentication.checkUserId( req.userId); const paramBoardId = req.params.boardId; -- cgit v1.2.3-1-g7c22 From 95f1772280d453c3ad55486806f17cb6b445359d Mon Sep 17 00:00:00 2001 From: zago Date: Thu, 29 Jun 2017 14:10:45 +0200 Subject: linebreaker fixing --- models/cards.js | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/models/cards.js b/models/cards.js index 3eb4c69f..a48690bf 100644 --- a/models/cards.js +++ b/models/cards.js @@ -420,34 +420,33 @@ if (Meteor.isServer) { }); }); - JsonRoutes.add('PUT', '/api/boards/:boardId/lists/:listId/cards/:cardId', function (req, res, next) { - Authentication.checkUserId( req.userId); - const paramBoardId = req.params.boardId; - const paramCardId = req.params.cardId; - const paramListId = req.params.listId; - if(req.body.title !== undefined){ - const newTitle = req.body.title; - Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, + JsonRoutes.add('PUT', '/api/boards/:boardId/lists/:listId/cards/:cardId', function (req, res, next) { + Authentication.checkUserId( req.userId); + const paramBoardId = req.params.boardId; + const paramCardId = req.params.cardId; + const paramListId = req.params.listId; + if(req.body.title !== undefined){ + const newTitle = req.body.title; + Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, {$set:{title:newTitle}}); - } - if(req.body.listId !== undefined){ - const newParamListId = req.body.listId; - Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, + } + if(req.body.listId !== undefined){ + const newParamListId = req.body.listId; + Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, {$set:{listId:newParamListId}}); - } - if(req.body.description !== undefined){ - const newDescription = req.body.description; - Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, + } + if(req.body.description !== undefined){ + const newDescription = req.body.description; + Cards.update({ _id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false }, {$set:{description:newDescription}}); - } - JsonRoutes.sendResult(res, { - code: 200, - data: { - _id: paramCardId, - }, - }); + } + JsonRoutes.sendResult(res, { + code: 200, + data: { + _id: paramCardId, + }, }); - + }); JsonRoutes.add('DELETE', '/api/boards/:boardId/lists/:listId/cards/:cardId', function (req, res, next) { -- cgit v1.2.3-1-g7c22 From 2c1509686d623008a2641b9741de3be7d3e3163a Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Thu, 29 Jun 2017 15:54:49 +0300 Subject: REST API: Add PUT method to update a card. Thanks to zarnifoulette ! Related to #1037 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4e4a3ec..a8bdbbe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# Upcoming Wekan release + +This release adds the following new features: + +* [REST API: Add PUT method to update a card](https://github.com/wekan/wekan/pull/1095). + +Thanks to GitHub user zarnifoulette for contributions! + # v0.27 2017-06-28 Wekan release This release adds the following new features: -- cgit v1.2.3-1-g7c22