mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
add cardNumber handling to card and board model
This commit is contained in:
parent
36c2cb9573
commit
b57eae14d4
3 changed files with 72 additions and 0 deletions
|
|
@ -375,6 +375,14 @@ Boards.attachSchema(
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
allowsCardNumber: {
|
||||||
|
/**
|
||||||
|
* Does the board allows card numbers?
|
||||||
|
*/
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
|
||||||
allowsActivities: {
|
allowsActivities: {
|
||||||
/**
|
/**
|
||||||
* Does the board allows comments?
|
* Does the board allows comments?
|
||||||
|
|
@ -1056,6 +1064,16 @@ Boards.helpers({
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getNextCardNumber() {
|
||||||
|
const boardCards = Cards.find({ boardId: this._id }).fetch();
|
||||||
|
if (boardCards.length == 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
const maxCardNumber = Math.max(...boardCards
|
||||||
|
.map(c => c.cardNumber ? c.cardNumber : 0));
|
||||||
|
return maxCardNumber + 1;
|
||||||
|
},
|
||||||
|
|
||||||
cardsDueInBetween(start, end) {
|
cardsDueInBetween(start, end) {
|
||||||
return Cards.find({
|
return Cards.find({
|
||||||
boardId: this._id,
|
boardId: this._id,
|
||||||
|
|
@ -1285,6 +1303,10 @@ Boards.mutations({
|
||||||
return { $set: { allowsDescriptionTitle } };
|
return { $set: { allowsDescriptionTitle } };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setAllowsCardNumber(allowsCardNumber) {
|
||||||
|
return { $set: { allowsCardNumber } };
|
||||||
|
},
|
||||||
|
|
||||||
setAllowsDescriptionText(allowsDescriptionText) {
|
setAllowsDescriptionText(allowsDescriptionText) {
|
||||||
return { $set: { allowsDescriptionText } };
|
return { $set: { allowsDescriptionText } };
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -470,6 +470,16 @@ Cards.attachSchema(
|
||||||
optional: true,
|
optional: true,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
},
|
},
|
||||||
|
cardNumber: {
|
||||||
|
/**
|
||||||
|
* A boardwise sequentially increasing number that is assigned
|
||||||
|
* to every newly created card
|
||||||
|
*/
|
||||||
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
|
optional: true,
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -1647,6 +1657,10 @@ Cards.helpers({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getCardNumber() {
|
||||||
|
return this.cardNumber;
|
||||||
|
},
|
||||||
|
|
||||||
getBoardTitle() {
|
getBoardTitle() {
|
||||||
if (this.isLinkedCard()) {
|
if (this.isLinkedCard()) {
|
||||||
const card = Cards.findOne({ _id: this.linkedId });
|
const card = Cards.findOne({ _id: this.linkedId });
|
||||||
|
|
@ -3207,6 +3221,8 @@ if (Meteor.isServer) {
|
||||||
Authentication.checkAdminOrCondition(req.userId, addPermission);
|
Authentication.checkAdminOrCondition(req.userId, addPermission);
|
||||||
const paramListId = req.params.listId;
|
const paramListId = req.params.listId;
|
||||||
const paramParentId = req.params.parentId;
|
const paramParentId = req.params.parentId;
|
||||||
|
|
||||||
|
const nextCardNumber = board.getNextCardNumber();
|
||||||
const currentCards = Cards.find(
|
const currentCards = Cards.find(
|
||||||
{
|
{
|
||||||
listId: paramListId,
|
listId: paramListId,
|
||||||
|
|
@ -3229,6 +3245,7 @@ if (Meteor.isServer) {
|
||||||
userId: req.body.authorId,
|
userId: req.body.authorId,
|
||||||
swimlaneId: req.body.swimlaneId,
|
swimlaneId: req.body.swimlaneId,
|
||||||
sort: currentCards.count(),
|
sort: currentCards.count(),
|
||||||
|
cardNumber: nextCardNumber,
|
||||||
members,
|
members,
|
||||||
assignees,
|
assignees,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1061,3 +1061,36 @@ Migrations.add('add-hide-logo-by-default', () => {
|
||||||
noValidateMulti,
|
noValidateMulti,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Migrations.add('add-card-number-allowed', () => {
|
||||||
|
Boards.update(
|
||||||
|
{
|
||||||
|
allowsCardNumber: {
|
||||||
|
$exists: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
allowsCardNumber: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
noValidateMulti,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Migrations.add('assign-boardwise-card-numbers', () => {
|
||||||
|
Boards.find().forEach(board => {
|
||||||
|
let nextCardNumber = 1;
|
||||||
|
Cards.find(
|
||||||
|
{
|
||||||
|
boardId: board._id,
|
||||||
|
cardNumber: {
|
||||||
|
$exists: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).forEach(card => {
|
||||||
|
Cards.update(card._id, { $set: { cardNumber } }, noValidate);
|
||||||
|
nextCardNumber++;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue