Merge pull request #4152 from mfilser/fix_list_add_to_bottom

Fix list adding to bottom
This commit is contained in:
Lauri Ojansivu 2021-11-15 20:14:41 +02:00 committed by GitHub
commit 7518d93feb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -237,13 +237,15 @@ BlazeComponent.extendComponent({
{
submit(evt) {
evt.preventDefault();
const lastList = this.currentBoard.getLastList();
const sortIndex = Utils.calculateIndexData(lastList, null).base;
const titleInput = this.find('.list-name-input');
const title = titleInput.value.trim();
if (title) {
Lists.insert({
title,
boardId: Session.get('currentBoard'),
sort: $('.list').length,
sort: sortIndex,
type: this.isListTemplatesSwimlane ? 'template-list' : 'list',
swimlaneId: this.currentBoard.isTemplatesBoard()
? this.currentSwimlane._id

View file

@ -693,10 +693,19 @@ Boards.helpers({
{ sort: sortKey },
);
},
draggableLists() {
return Lists.find({ boardId: this._id }, { sort: { sort: 1 } });
},
/** returns the last list
* @returns Document the last list
*/
getLastList() {
const ret = Lists.findOne({ boardId: this._id }, { sort: { sort: 'desc' } });
return ret;
},
nullSortLists() {
return Lists.find({
boardId: this._id,