浏览代码

Checklistitems are now inserted always at the end of the checklist

Martin Filser 4 年之前
父节点
当前提交
e8b6b78dfa
共有 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,
         checklistId: checklist._id,
         cardId: checklist.cardId,
-        sort: checklist.itemCount(),
+        sort: Utils.calculateIndexData(checklist.lastItem()).base,
       });
     }
     // We keep the form opened, empty it.

+ 5 - 0
models/checklists.js

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