mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 21:17:18 -04:00
fixes retrieval of next board cardnumber
This commit is contained in:
parent
236b6c3552
commit
e8522c323f
1 changed files with 17 additions and 2 deletions
|
@ -1065,8 +1065,23 @@ Boards.helpers({
|
|||
},
|
||||
|
||||
getNextCardNumber() {
|
||||
const boardCards = Cards.find({ boardId: this._id }).fetch();
|
||||
return boardCards.length + 1;
|
||||
const boardCards = Cards.find(
|
||||
{
|
||||
boardId: this._id
|
||||
},
|
||||
{
|
||||
sort: { cardNumber: -1 },
|
||||
limit: 1
|
||||
}
|
||||
).fetch();
|
||||
|
||||
// If no card is assigned to the board, return 1
|
||||
if (!boardCards || boardCards.length === 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const maxCardNr = !!boardCards[0].cardNumber ? boardCards[0].cardNumber : 0;
|
||||
return maxCardNr + 1;
|
||||
},
|
||||
|
||||
cardsDueInBetween(start, end) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue