Browse Source

Merge branch 'GhassenRjab-hotfix/sort-checklists-items' into devel

Fix: Checklist items are lost when moving items to
another checklist. Thanks to GhassenRjab ! Related #876
Lauri Ojansivu 7 years ago
parent
commit
5f697eac05
2 changed files with 33 additions and 1 deletions
  1. 7 1
      CHANGELOG.md
  2. 26 0
      server/migrations.js

+ 7 - 1
CHANGELOG.md

@@ -1,9 +1,15 @@
 # Upcoming Wekan release
 
+This release adds the following new features:
+
 * [Add translations (en/de/fi) for email notifications regarding checklists and checklist
    items](https://github.com/wekan/wekan/pull/1238).
 
-Thanks to GitHub users umbertooo and xet7 for their contributions.
+and fixes the following bugs:
+
+* [Checklist items are lost when moving items to another checklist](https://github.com/wekan/wekan/pull/1240).
+
+Thanks to GitHub users GhassenRjab, umbertooo and xet7 for their contributions.
 
 # v0.39 2017-09-18 Wekan release
 

+ 26 - 0
server/migrations.js

@@ -130,3 +130,29 @@ Migrations.add('add-member-isactive-field', () => {
     Boards.update(board._id, {$set: {members: newMemberSet}}, noValidate);
   });
 });
+
+Migrations.add('add-sort-checklists', () => {
+  Checklists.find().forEach((checklist, index) => {
+    if (!checklist.hasOwnProperty('sort')) {
+      Checklists.direct.update(
+        checklist._id,
+        {
+          $set: {
+            sort: index,
+            newItemIndex: checklist.items.length,
+          },
+        },
+        noValidate
+      );
+    }
+    checklist.items.forEach(function(item, index) {
+      if (!item.hasOwnProperty('sort')) {
+        Checklists.direct.update(
+          { _id: checklist._id, 'items._id': item._id },
+          { $set: { 'items.$.sort': index } },
+          noValidate
+        );
+      }
+    });
+  });
+});