Browse Source

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.
Benjamin Tissoires 7 năm trước cách đây
mục cha
commit
2ce1ba37a1
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      models/cards.js

+ 8 - 2
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}});
     }