Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
2ce1ba37a1
1 zmenil súbory, kde vykonal 8 pridanie a 2 odobranie
  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}});
     }