浏览代码

Merge pull request #3551 from mfilser/checklistitems-not_always_insert_at_the_end

Checklistitems are now inserted always at the end of the checklist
Lauri Ojansivu 4 年之前
父节点
当前提交
89be0f80b9
共有 2 个文件被更改,包括 6 次插入1 次删除
  1. 1 1
      client/components/cards/checklists.js
  2. 5 0
      models/checklists.js

+ 1 - 1
client/components/cards/checklists.js

@@ -111,7 +111,7 @@ BlazeComponent.extendComponent({
         title,
         title,
         checklistId: checklist._id,
         checklistId: checklist._id,
         cardId: checklist.cardId,
         cardId: checklist.cardId,
-        sort: checklist.itemCount(),
+        sort: Utils.calculateIndexData(checklist.lastItem()).base,
       });
       });
     }
     }
     // We keep the form opened, empty it.
     // We keep the form opened, empty it.

+ 5 - 0
models/checklists.js

@@ -91,6 +91,11 @@ Checklists.helpers({
       { sort: ['sort'] },
       { sort: ['sort'] },
     );
     );
   },
   },
+  lastItem() {
+    const allItems = this.items().fetch();
+    const ret = allItems[allItems.length - 1];
+    return ret;
+  },
   finishedCount() {
   finishedCount() {
     return ChecklistItems.find({
     return ChecklistItems.find({
       checklistId: this._id,
       checklistId: this._id,