diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-05-08 11:14:26 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-05-08 11:14:26 +0300 |
commit | 0ecbb734198280de83f1e306647e5d9d8a3ffef8 (patch) | |
tree | 0ed596f95d3b46a0080a8869dab90a3b177b8365 /models/boards.js | |
parent | daeb06f7b793f2e9f7590296e45b3d129ccb0a3a (diff) | |
parent | f3aa524b773f746d44c69fb432b6905bd139792d (diff) | |
download | wekan-0ecbb734198280de83f1e306647e5d9d8a3ffef8.tar.gz wekan-0ecbb734198280de83f1e306647e5d9d8a3ffef8.tar.bz2 wekan-0ecbb734198280de83f1e306647e5d9d8a3ffef8.zip |
Merge branch 'devel'
Diffstat (limited to 'models/boards.js')
-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, + }); + } + }); } |