summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2018-06-26 20:59:04 +0200
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>2018-10-24 16:55:27 +0200
commit2ce1ba37a1d0a09f8b3d2a1db4c8a11d1f98caa0 (patch)
tree18cab603cbd1bad97514a7a6e3fa3fa4230bcfed /models
parent6d4ffdd8b4fa332c2257edcade92391b8e85d9c6 (diff)
downloadwekan-2ce1ba37a1d0a09f8b3d2a1db4c8a11d1f98caa0.tar.gz
wekan-2ce1ba37a1d0a09f8b3d2a1db4c8a11d1f98caa0.tar.bz2
wekan-2ce1ba37a1d0a09f8b3d2a1db4c8a11d1f98caa0.zip
models: cards: allow singletons to be assigned to members and labelIds
If we need to set only one member or one label, the data provided will not give us an array, but the only element as a string. We need to detect that and convert the parameter into an array.
Diffstat (limited to 'models')
-rw-r--r--models/cards.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/models/cards.js b/models/cards.js
index 9bb67f41..a9745f92 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -1457,7 +1457,10 @@ if (Meteor.isServer) {
});
}
if (req.body.hasOwnProperty('labelIds')) {
- const newlabelIds = req.body.labelIds;
+ let newlabelIds = req.body.labelIds;
+ if (_.isString(newlabelIds)) {
+ newlabelIds = [newlabelIds];
+ }
Cards.direct.update({
_id: paramCardId,
listId: paramListId,
@@ -1515,7 +1518,10 @@ if (Meteor.isServer) {
{$set: {customFields: newcustomFields}});
}
if (req.body.hasOwnProperty('members')) {
- const newmembers = req.body.members;
+ let newmembers = req.body.members;
+ if (_.isString(newmembers)) {
+ newmembers = [newmembers];
+ }
Cards.direct.update({_id: paramCardId, listId: paramListId, boardId: paramBoardId, archived: false},
{$set: {members: newmembers}});
}