mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 07:50:12 +01:00
Update Checklists client
Use new methods added in Checklist model
This commit is contained in:
parent
28eca2a11f
commit
c3cccfc66e
2 changed files with 14 additions and 12 deletions
|
|
@ -47,7 +47,7 @@ template(name="editChecklistItemForm")
|
||||||
|
|
||||||
template(name="checklistItems")
|
template(name="checklistItems")
|
||||||
.checklist-items.js-checklist-items
|
.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)
|
+inlinedForm(classNames="js-edit-checklist-item" item = item checklist = checklist)
|
||||||
+editChecklistItemForm(type = 'item' item = item checklist = checklist)
|
+editChecklistItemForm(type = 'item' item = item checklist = checklist)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -20,24 +20,26 @@ function initSorting(items) {
|
||||||
});
|
});
|
||||||
items.sortable('cancel');
|
items.sortable('cancel');
|
||||||
const formerParent = ui.item.parents('.js-checklist-items');
|
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;
|
const oldChecklist = Blaze.getData(formerParent.get(0)).checklist;
|
||||||
if (oldChecklist._id !== checklist._id) {
|
if (oldChecklist._id !== checklist._id) {
|
||||||
const currentItem = Blaze.getData(ui.item.get(0)).item;
|
const currentItem = Blaze.getData(ui.item.get(0)).item;
|
||||||
for (let i = 0; i < orderedItems.length; i++) {
|
for (let i = 0; i < orderedItems.length; i++) {
|
||||||
let itemId = orderedItems[i];
|
const itemId = orderedItems[i];
|
||||||
if (itemId !== currentItem._id) continue;
|
if (itemId !== currentItem._id) continue;
|
||||||
checklist.addItem(currentItem.title);
|
const newItem = {
|
||||||
checklist = Checklists.findOne({_id: checklist._id});
|
_id: checklist.getNewItemId(),
|
||||||
itemId = checklist._id + (checklist.newItemIndex - 1);
|
title: currentItem.title,
|
||||||
if (currentItem.finished) {
|
sort: i,
|
||||||
checklist.finishItem(itemId);
|
isFinished: currentItem.isFinished,
|
||||||
}
|
};
|
||||||
orderedItems[i] = itemId;
|
checklist.addFullItem(newItem);
|
||||||
oldChecklist.removeItem(currentItem._id);
|
orderedItems[i] = currentItem._id;
|
||||||
}
|
oldChecklist.removeItem(itemId);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
checklist.sortItems(orderedItems);
|
checklist.sortItems(orderedItems);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue