mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
List add always at the end of all lists
- if a sort number is higher than the count of lists, the list wasn't added at the end
This commit is contained in:
parent
fa9641ba7b
commit
0fb6b6e519
2 changed files with 12 additions and 1 deletions
|
|
@ -237,13 +237,15 @@ BlazeComponent.extendComponent({
|
||||||
{
|
{
|
||||||
submit(evt) {
|
submit(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
const lastList = this.currentBoard.getLastList();
|
||||||
|
const sortIndex = Utils.calculateIndexData(lastList, null).base;
|
||||||
const titleInput = this.find('.list-name-input');
|
const titleInput = this.find('.list-name-input');
|
||||||
const title = titleInput.value.trim();
|
const title = titleInput.value.trim();
|
||||||
if (title) {
|
if (title) {
|
||||||
Lists.insert({
|
Lists.insert({
|
||||||
title,
|
title,
|
||||||
boardId: Session.get('currentBoard'),
|
boardId: Session.get('currentBoard'),
|
||||||
sort: $('.js-list').length,
|
sort: sortIndex,
|
||||||
type: this.isListTemplatesSwimlane ? 'template-list' : 'list',
|
type: this.isListTemplatesSwimlane ? 'template-list' : 'list',
|
||||||
swimlaneId: this.currentBoard.isTemplatesBoard()
|
swimlaneId: this.currentBoard.isTemplatesBoard()
|
||||||
? this.currentSwimlane._id
|
? this.currentSwimlane._id
|
||||||
|
|
|
||||||
|
|
@ -693,10 +693,19 @@ Boards.helpers({
|
||||||
{ sort: sortKey },
|
{ sort: sortKey },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
draggableLists() {
|
draggableLists() {
|
||||||
return Lists.find({ boardId: this._id }, { sort: { sort: 1 } });
|
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() {
|
nullSortLists() {
|
||||||
return Lists.find({
|
return Lists.find({
|
||||||
boardId: this._id,
|
boardId: this._id,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue