diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-05-08 01:27:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-08 01:27:09 +0300 |
commit | da180472c16ca4504ca9a1cab2a8553050a45d55 (patch) | |
tree | 10d4706f961e07947764b2e06e10186166e4ac58 | |
parent | cdc2b920ee9c729c6ba796a4d4653f76a82574d7 (diff) | |
parent | 6b2d022a93114e39b26396aeb21b68a51551da84 (diff) | |
download | wekan-da180472c16ca4504ca9a1cab2a8553050a45d55.tar.gz wekan-da180472c16ca4504ca9a1cab2a8553050a45d55.tar.bz2 wekan-da180472c16ca4504ca9a1cab2a8553050a45d55.zip |
Merge pull request #1630 from ThisNeko/devel
Add a new API route to create a new label in a given board
-rw-r--r-- | models/boards.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index 3e05b499..c863c5ce 100644 --- a/models/boards.js +++ b/models/boards.js @@ -719,4 +719,33 @@ if (Meteor.isServer) { }); } }); + + JsonRoutes.add('PUT', '/api/boards/:id/labels', function (req, res) { + Authentication.checkUserId(req.userId); + const id = req.params.id; + try { + if (req.body.hasOwnProperty('label')) { + const board = Boards.findOne({ _id: id }); + const color = req.body.label.color; + const name = req.body.label.name; + const labelId = Random.id(6); + if (!board.getLabel(name, color)) { + Boards.direct.update({ _id: id }, { $push: { labels: { _id: labelId, name, color } } }); + JsonRoutes.sendResult(res, { + code: 200, + data: labelId, + }); + } else { + JsonRoutes.sendResult(res, { + code: 200, + }); + } + } + } + catch (error) { + JsonRoutes.sendResult(res, { + data: error, + }); + } + }); } |