Explorar o código

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 %!s(int64=7) %!d(string=hai) anos
pai
achega
2ce1ba37a1
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  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}});
     }