瀏覽代碼

Merge pull request #3706 from jrsupplee/issue-3703

Bug fix: Rules for moving from list/swimlane
Lauri Ojansivu 4 年之前
父節點
當前提交
378d64f99a
共有 2 個文件被更改,包括 22 次插入9 次删除
  1. 6 5
      models/cards.js
  2. 16 4
      server/rulesHelper.js

+ 6 - 5
models/cards.js

@@ -2321,11 +2321,12 @@ if (Meteor.isServer) {
       const card = Cards.findOne(doc._id);
       const list = card.list();
       if (list) {
-        // change list modifiedAt, when user modified the key values in timingaction array, if it's endAt, put the modifiedAt of list back to one year ago for sorting purpose
-        const modifiedAt = new Date(
-          new Date(value).getTime() -
-            (action === 'endAt' ? 365 * 24 * 3600 * 1e3 : 0),
-        ); // set it as 1 year before
+        // change list modifiedAt, when user modified the key values in
+        // timingaction array, if it's endAt, put the modifiedAt of list
+        // back to one year ago for sorting purpose
+        const modifiedAt = moment()
+          .subtract(1, 'year')
+          .toISOString();
         const boardId = list.boardId;
         Lists.direct.update(
           {

+ 16 - 4
server/rulesHelper.js

@@ -29,14 +29,26 @@ RulesHelper = {
   },
   buildMatchingFieldsMap(activity, matchingFields) {
     const matchingMap = { activityType: activity.activityType };
-    for (let i = 0; i < matchingFields.length; i++) {
+    matchingFields.forEach(field => {
       // Creating a matching map with the actual field of the activity
       // and with the wildcard (for example: trigger when a card is added
       // in any [*] board
-      matchingMap[matchingFields[i]] = {
-        $in: [activity[matchingFields[i]], '*'],
+      let value = activity[field];
+      if (field === 'oldListName') {
+        const oldList = Lists.findOne({ _id: activity.oldListId });
+        if (oldList) {
+          value = oldList.title;
+        }
+      } else if (field === 'oldSwimlaneName') {
+        const oldSwimlane = Swimlanes.findOne({ _id: activity.oldSwimlaneId });
+        if (oldSwimlane) {
+          value = oldSwimlane.title;
+        }
+      }
+      matchingMap[field] = {
+        $in: [value, '*'],
       };
-    }
+    });
     return matchingMap;
   },
   performAction(activity, action) {