mirror of
https://github.com/wekan/wekan.git
synced 2026-02-09 01:34:21 +01:00
parent
77041e0d74
commit
f8aa487e91
3 changed files with 47 additions and 11 deletions
|
|
@ -1030,7 +1030,8 @@ Template.editCardAssignerForm.events({
|
|||
}
|
||||
} else {
|
||||
// If no card selected, move to end
|
||||
sortIndex = card.getMaxSort(options.listId, options.swimlaneId) + 1;
|
||||
const maxSort = card.getMaxSort(options.listId, options.swimlaneId);
|
||||
sortIndex = maxSort !== null ? maxSort + 1 : 0;
|
||||
}
|
||||
|
||||
await card.move(options.boardId, options.swimlaneId, options.listId, sortIndex);
|
||||
|
|
@ -1073,7 +1074,8 @@ Template.editCardAssignerForm.events({
|
|||
}
|
||||
} else {
|
||||
// If no card selected, copy to end
|
||||
sortIndex = newCard.getMaxSort(options.listId, options.swimlaneId) + 1;
|
||||
const maxSort = newCard.getMaxSort(options.listId, options.swimlaneId);
|
||||
sortIndex = maxSort !== null ? maxSort + 1 : 0;
|
||||
}
|
||||
|
||||
await newCard.move(options.boardId, options.swimlaneId, options.listId, sortIndex);
|
||||
|
|
@ -1125,7 +1127,8 @@ Template.editCardAssignerForm.events({
|
|||
}
|
||||
}
|
||||
} else {
|
||||
sortIndex = newCard.getMaxSort(options.listId, options.swimlaneId) + 1;
|
||||
const maxSort = newCard.getMaxSort(options.listId, options.swimlaneId);
|
||||
sortIndex = maxSort !== null ? maxSort + 1 : 0;
|
||||
}
|
||||
|
||||
await newCard.move(options.boardId, options.swimlaneId, options.listId, sortIndex);
|
||||
|
|
@ -1170,7 +1173,8 @@ Template.editCardAssignerForm.events({
|
|||
}
|
||||
}
|
||||
} else {
|
||||
sortIndex = newCard.getMaxSort(options.listId, options.swimlaneId) + 1;
|
||||
const maxSort = newCard.getMaxSort(options.listId, options.swimlaneId);
|
||||
sortIndex = maxSort !== null ? maxSort + 1 : 0;
|
||||
}
|
||||
|
||||
await newCard.move(options.boardId, options.swimlaneId, options.listId, sortIndex);
|
||||
|
|
|
|||
|
|
@ -73,12 +73,37 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
|
|||
/** sets the first list id */
|
||||
setFirstListId() {
|
||||
try {
|
||||
const board = ReactiveCache.getBoard(this.selectedBoardId.get());
|
||||
const listId = board.lists()[0]._id;
|
||||
const boardId = this.selectedBoardId.get();
|
||||
const swimlaneId = this.selectedSwimlaneId.get();
|
||||
const lists = this.getListsForBoardSwimlane(boardId, swimlaneId);
|
||||
const listId = lists[0] ? lists[0]._id : '';
|
||||
this.selectedListId.set(listId);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
/** get lists filtered by board and swimlane */
|
||||
getListsForBoardSwimlane(boardId, swimlaneId) {
|
||||
if (!boardId) return [];
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
if (!board) return [];
|
||||
|
||||
const selector = {
|
||||
boardId,
|
||||
archived: false,
|
||||
};
|
||||
|
||||
if (swimlaneId) {
|
||||
const defaultSwimlane = board.getDefaultSwimline && board.getDefaultSwimline();
|
||||
if (defaultSwimlane && defaultSwimlane._id === swimlaneId) {
|
||||
selector.swimlaneId = { $in: [swimlaneId, null, ''] };
|
||||
} else {
|
||||
selector.swimlaneId = swimlaneId;
|
||||
}
|
||||
}
|
||||
|
||||
return ReactiveCache.getLists(selector, { sort: { sort: 1 } });
|
||||
}
|
||||
|
||||
/** returns if the board id was the last confirmed one
|
||||
* @param boardId check this board id
|
||||
* @return if the board id was the last confirmed one
|
||||
|
|
@ -130,9 +155,10 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
|
|||
|
||||
/** returns all available lists of the current board */
|
||||
lists() {
|
||||
const board = ReactiveCache.getBoard(this.selectedBoardId.get());
|
||||
const ret = board.lists();
|
||||
return ret;
|
||||
return this.getListsForBoardSwimlane(
|
||||
this.selectedBoardId.get(),
|
||||
this.selectedSwimlaneId.get(),
|
||||
);
|
||||
}
|
||||
|
||||
/** Fix swimlane title translation issue for "Default" swimlane
|
||||
|
|
@ -214,6 +240,7 @@ export class DialogWithBoardSwimlaneList extends BlazeComponent {
|
|||
},
|
||||
'change .js-select-swimlanes'(event) {
|
||||
this.selectedSwimlaneId.set($(event.currentTarget).val());
|
||||
this.setFirstListId();
|
||||
},
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -37,8 +37,9 @@ export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList
|
|||
/** returns all available cards of the current list */
|
||||
cards() {
|
||||
const list = ReactiveCache.getList({_id: this.selectedListId.get(), boardId: this.selectedBoardId.get()});
|
||||
if (list) {
|
||||
return list.cards();
|
||||
const swimlaneId = this.selectedSwimlaneId.get();
|
||||
if (list && swimlaneId) {
|
||||
return list.cards(swimlaneId).sort((a, b) => a.sort - b.sort);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
|
|
@ -112,12 +113,16 @@ export class DialogWithBoardSwimlaneListCard extends DialogWithBoardSwimlaneList
|
|||
},
|
||||
'change .js-select-swimlanes'(event) {
|
||||
this.selectedSwimlaneId.set($(event.currentTarget).val());
|
||||
this.setFirstListId();
|
||||
},
|
||||
'change .js-select-lists'(event) {
|
||||
this.selectedListId.set($(event.currentTarget).val());
|
||||
// Reset card selection when list changes
|
||||
this.selectedCardId.set('');
|
||||
},
|
||||
'change .js-select-cards'(event) {
|
||||
this.selectedCardId.set($(event.currentTarget).val());
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue