From fa9641ba7bda47e8bd825229994e87ef4fd59ba6 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 15 Nov 2021 15:12:42 +0100 Subject: [PATCH 1/2] Fix adding list at mobile view, every list had a sort number 1 - html class list doesn't exist at mobile view. class js-list exists on mobile and desktop view --- client/components/swimlanes/swimlanes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index 08e6730d5..1ea2bc861 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -243,7 +243,7 @@ BlazeComponent.extendComponent({ Lists.insert({ title, boardId: Session.get('currentBoard'), - sort: $('.list').length, + sort: $('.js-list').length, type: this.isListTemplatesSwimlane ? 'template-list' : 'list', swimlaneId: this.currentBoard.isTemplatesBoard() ? this.currentSwimlane._id From 0fb6b6e519f1cd4830f3b513b752915c0f65b7e3 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 15 Nov 2021 17:31:42 +0100 Subject: [PATCH 2/2] 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 --- client/components/swimlanes/swimlanes.js | 4 +++- models/boards.js | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index 1ea2bc861..1674ea1ac 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -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: $('.js-list').length, + sort: sortIndex, type: this.isListTemplatesSwimlane ? 'template-list' : 'list', swimlaneId: this.currentBoard.isTemplatesBoard() ? this.currentSwimlane._id diff --git a/models/boards.js b/models/boards.js index ecc0d28b6..1195b5891 100644 --- a/models/boards.js +++ b/models/boards.js @@ -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,