mirror of
https://github.com/wekan/wekan.git
synced 2025-04-20 12:07:11 -04:00
Add checklist-item at top
This commit is contained in:
parent
6fead14c11
commit
23595674cf
3 changed files with 22 additions and 1 deletions
|
@ -92,6 +92,13 @@ template(name="editChecklistItemForm")
|
|||
| {{_ 'convertChecklistItemToCardPopup-title'}}
|
||||
|
||||
template(name="checklistItems")
|
||||
if checklist.items.count
|
||||
if canModifyCard
|
||||
+inlinedForm(autoclose=false classNames="js-add-checklist-item" checklist = checklist position="top")
|
||||
+addChecklistItemForm(checklist=checklist showNewlineBecomesNewChecklistItem=true)
|
||||
else
|
||||
a.add-checklist-item.js-open-inlined-form(title="{{_ 'add-checklist-item'}}")
|
||||
i.fa.fa-plus
|
||||
.checklist-items.js-checklist-items
|
||||
each item in checklist.items
|
||||
+inlinedForm(classNames="js-edit-checklist-item" item = item checklist = checklist)
|
||||
|
|
|
@ -132,13 +132,22 @@ BlazeComponent.extendComponent({
|
|||
let checklistItems = [title];
|
||||
if (newlineBecomesNewChecklistItem.checked) {
|
||||
checklistItems = title.split('\n').map(_value => _value.trim());
|
||||
if (this.currentData().position === 'top') {
|
||||
checklistItems = checklistItems.reverse();
|
||||
}
|
||||
}
|
||||
for (let checklistItem of checklistItems) {
|
||||
let sortIndex;
|
||||
if (this.currentData().position === 'top') {
|
||||
sortIndex = Utils.calculateIndexData(null, checklist.firstItem()).base;
|
||||
} else {
|
||||
sortIndex = Utils.calculateIndexData(checklist.lastItem(), null).base;
|
||||
}
|
||||
ChecklistItems.insert({
|
||||
title: checklistItem,
|
||||
checklistId: checklist._id,
|
||||
cardId: checklist.cardId,
|
||||
sort: Utils.calculateIndexData(checklist.lastItem()).base,
|
||||
sort: sortIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,11 @@ Checklists.helpers({
|
|||
{ sort: ['sort'] },
|
||||
);
|
||||
},
|
||||
firstItem() {
|
||||
const allItems = this.items().fetch();
|
||||
const ret = _.first(allItems);
|
||||
return ret;
|
||||
},
|
||||
lastItem() {
|
||||
const allItems = this.items().fetch();
|
||||
const ret = allItems[allItems.length - 1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue