mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 15:49:46 +02:00
ref: Remove board types, refactoring
This commit is contained in:
parent
2b131f76c1
commit
6ffa817b53
182 changed files with 1573 additions and 1239 deletions
|
@ -1,41 +1,17 @@
|
|||
const LIMIT = 10;
|
||||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
recordOrIdOrIds: {
|
||||
type: 'ref',
|
||||
custom: (value) => _.isObjectLike(value) || _.isString(value) || _.every(value, _.isString),
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
beforeId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const criteria = {};
|
||||
|
||||
let sort;
|
||||
let limit;
|
||||
|
||||
if (_.isObjectLike(inputs.recordOrIdOrIds)) {
|
||||
criteria.boardId = inputs.recordOrIdOrIds.id;
|
||||
|
||||
if (inputs.recordOrIdOrIds.type === Board.Types.KANBAN) {
|
||||
sort = 'position';
|
||||
} else if (inputs.recordOrIdOrIds.type === Board.Types.COLLECTION) {
|
||||
if (inputs.beforeId) {
|
||||
criteria.id = {
|
||||
'<': inputs.beforeId,
|
||||
};
|
||||
}
|
||||
|
||||
limit = LIMIT;
|
||||
}
|
||||
} else {
|
||||
criteria.boardId = inputs.recordOrIdOrIds;
|
||||
}
|
||||
|
||||
return sails.helpers.cards.getMany(criteria, sort, limit);
|
||||
return sails.helpers.cards.getMany({
|
||||
boardId: inputs.idOrIds,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue