insert linked card, move sortIndex to function

This commit is contained in:
Martin Filser 2023-01-14 17:52:27 +01:00
parent 29216599e4
commit c29cff3822

View file

@ -498,6 +498,19 @@ BlazeComponent.extendComponent({
}); });
}, },
getSortIndex() {
const position = this.currentData().position;
let ret;
if (position === 'top') {
const firstCardDom = this.list.find('.js-minicard:first')[0];
ret = Utils.calculateIndex(null, firstCardDom).base;
} else if (position === 'bottom') {
const lastCardDom = this.list.find('.js-minicard:last')[0];
ret = Utils.calculateIndex(lastCardDom, null).base;
}
return ret;
},
events() { events() {
return [ return [
{ {
@ -520,15 +533,7 @@ BlazeComponent.extendComponent({
Popup.back(); Popup.back();
return; return;
} }
const position = this.currentData().position; const sortIndex = this.getSortIndex();
let sortIndex;
if (position === 'top') {
const firstCardDom = this.list.find('.js-minicard:first')[0];
sortIndex = Utils.calculateIndex(null, firstCardDom).base;
} else if (position === 'bottom') {
const lastCardDom = this.list.find('.js-minicard:last')[0];
sortIndex = Utils.calculateIndex(lastCardDom, null).base;
}
const _id = Cards.insert({ const _id = Cards.insert({
title: $('.js-select-cards option:selected').text(), //dummy title: $('.js-select-cards option:selected').text(), //dummy
listId: this.listId, listId: this.listId,