summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-05-08 01:27:09 +0300
committerGitHub <noreply@github.com>2018-05-08 01:27:09 +0300
commitda180472c16ca4504ca9a1cab2a8553050a45d55 (patch)
tree10d4706f961e07947764b2e06e10186166e4ac58
parentcdc2b920ee9c729c6ba796a4d4653f76a82574d7 (diff)
parent6b2d022a93114e39b26396aeb21b68a51551da84 (diff)
downloadwekan-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.js29
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,
+ });
+ }
+ });
}