diff options
author | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-09-24 02:15:33 +0100 |
---|---|---|
committer | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-09-24 02:15:33 +0100 |
commit | c3cccfc66ec4481959941fea25340595280cdfa2 (patch) | |
tree | 1d75c0e4f39dc54a68eede79ec5155282251606e /client | |
parent | 28eca2a11fd789b280b140bebf87c61a3e63f4f4 (diff) | |
download | wekan-c3cccfc66ec4481959941fea25340595280cdfa2.tar.gz wekan-c3cccfc66ec4481959941fea25340595280cdfa2.tar.bz2 wekan-c3cccfc66ec4481959941fea25340595280cdfa2.zip |
Update Checklists client
Use new methods added in Checklist model
Diffstat (limited to 'client')
-rw-r--r-- | client/components/cards/checklists.jade | 2 | ||||
-rw-r--r-- | client/components/cards/checklists.js | 24 |
2 files changed, 14 insertions, 12 deletions
diff --git a/client/components/cards/checklists.jade b/client/components/cards/checklists.jade index 7ecc5dd3..e1dd1d14 100644 --- a/client/components/cards/checklists.jade +++ b/client/components/cards/checklists.jade @@ -47,7 +47,7 @@ template(name="editChecklistItemForm") template(name="checklistItems") .checklist-items.js-checklist-items - each item in checklist.getItems + each item in checklist.getItemsSorted +inlinedForm(classNames="js-edit-checklist-item" item = item checklist = checklist) +editChecklistItemForm(type = 'item' item = item checklist = checklist) else diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js index bd9d275a..ba3384a9 100644 --- a/client/components/cards/checklists.js +++ b/client/components/cards/checklists.js @@ -20,24 +20,26 @@ function initSorting(items) { }); items.sortable('cancel'); const formerParent = ui.item.parents('.js-checklist-items'); - let checklist = Blaze.getData(parent.get(0)).checklist; + const checklist = Blaze.getData(parent.get(0)).checklist; const oldChecklist = Blaze.getData(formerParent.get(0)).checklist; if (oldChecklist._id !== checklist._id) { const currentItem = Blaze.getData(ui.item.get(0)).item; for (let i = 0; i < orderedItems.length; i++) { - let itemId = orderedItems[i]; + const itemId = orderedItems[i]; if (itemId !== currentItem._id) continue; - checklist.addItem(currentItem.title); - checklist = Checklists.findOne({_id: checklist._id}); - itemId = checklist._id + (checklist.newItemIndex - 1); - if (currentItem.finished) { - checklist.finishItem(itemId); - } - orderedItems[i] = itemId; - oldChecklist.removeItem(currentItem._id); + const newItem = { + _id: checklist.getNewItemId(), + title: currentItem.title, + sort: i, + isFinished: currentItem.isFinished, + }; + checklist.addFullItem(newItem); + orderedItems[i] = currentItem._id; + oldChecklist.removeItem(itemId); } + } else { + checklist.sortItems(orderedItems); } - checklist.sortItems(orderedItems); }, }); } |