summaryrefslogtreecommitdiffstats
path: root/client/components/cards/checklists.js
diff options
context:
space:
mode:
authoramadilsons <joao.amado.95@gmail.com>2017-09-27 14:42:18 +0200
committeramadilsons <joao.amado.95@gmail.com>2017-09-27 14:42:18 +0200
commit75f15f1be218bbfc4a06c0c57c4b1043091b5dc8 (patch)
treeef94de1a5a5ed5f975d00423075014987f6b6bc4 /client/components/cards/checklists.js
parentbbe37cfad83f261e2c24cca3b4f31baa0e818f58 (diff)
parenteb945f26a3be316fb2ae4452d6db45a11f8b91d4 (diff)
downloadwekan-75f15f1be218bbfc4a06c0c57c4b1043091b5dc8.tar.gz
wekan-75f15f1be218bbfc4a06c0c57c4b1043091b5dc8.tar.bz2
wekan-75f15f1be218bbfc4a06c0c57c4b1043091b5dc8.zip
Merge branch 'master' of https://github.com/wekan/wekan into issue881
Diffstat (limited to 'client/components/cards/checklists.js')
-rw-r--r--client/components/cards/checklists.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js
index 257f1ec8..0596d7eb 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);
},
});
}