Add checklist at top

This commit is contained in:
Martin Filser 2022-05-04 23:19:19 +02:00
parent 3c1eff6241
commit 52d54f35a3
4 changed files with 45 additions and 2 deletions

View file

@ -97,16 +97,26 @@ BlazeComponent.extendComponent({
//if (card.isLinked()) cardId = card.linkedId;
if (card.isLinkedCard()) cardId = card.linkedId;
let sortIndex;
let checklistItemIndex;
if (this.currentData().position === 'top') {
sortIndex = Utils.calculateIndexData(null, card.firstChecklist()).base;
checklistItemIndex = 0;
} else {
sortIndex = Utils.calculateIndexData(card.lastChecklist(), null).base;
checklistItemIndex = -1;
}
if (title) {
Checklists.insert({
cardId,
title,
sort: card.checklists().count(),
sort: sortIndex,
});
this.closeAllInlinedForms();
setTimeout(() => {
this.$('.add-checklist-item')
.last()
.eq(checklistItemIndex)
.click();
}, 100);
}