1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-23 07:09:44 +02:00

Prepare for collection board type, refactoring, update dependencies

This commit is contained in:
Maksim Eltyshev 2020-08-04 01:32:46 +05:00
parent 2d92ade8dc
commit c6ee7d54bb
190 changed files with 2144 additions and 1817 deletions

View file

@ -1,16 +1,42 @@
const LIMIT = 10;
module.exports = {
inputs: {
id: {
type: 'json',
custom: (value) => _.isString(value) || _.isArray(value),
recordOrId: {
type: 'ref',
custom: (value) => _.isObjectLike(value) || _.isString(value) || _.every(value, _.isString),
required: true,
},
beforeId: {
type: 'string',
},
},
async fn(inputs, exits) {
const cards = await sails.helpers.getCards({
boardId: inputs.id,
});
const criteria = {};
let sort;
let limit;
if (_.isObjectLike(inputs.recordOrId)) {
criteria.boardId = inputs.recordOrId.id;
if (inputs.recordOrId.type === 'kanban') {
sort = 'position';
} else if (inputs.recordOrId.type === 'collection') {
if (inputs.beforeId) {
criteria.id = {
'<': inputs.beforeId,
};
}
limit = LIMIT;
}
} else {
criteria.boardId = inputs.recordOrId;
}
const cards = await sails.helpers.getCards(criteria, sort, limit);
return exits.success(cards);
},