Преглед на файлове

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 години
родител
ревизия
2ce1ba37a1
променени са 1 файла, в които са добавени 8 реда и са изтрити 2 реда
  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}});
     }