mirror of
https://github.com/plankanban/planka.git
synced 2025-07-25 08:09:44 +02:00
parent
ddf9a32ea9
commit
ad67b9ba24
27 changed files with 341 additions and 94 deletions
|
@ -11,6 +11,10 @@ module.exports = {
|
|||
regex: /^[0-9]+$/,
|
||||
required: true,
|
||||
},
|
||||
position: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
|
@ -39,7 +43,7 @@ module.exports = {
|
|||
throw Errors.CARD_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
const values = _.pick(inputs, ['name', 'isCompleted']);
|
||||
const values = _.pick(inputs, ['position', 'name', 'isCompleted']);
|
||||
const task = await sails.helpers.tasks.createOne(values, card, this.req);
|
||||
|
||||
return {
|
||||
|
|
|
@ -11,6 +11,9 @@ module.exports = {
|
|||
regex: /^[0-9]+$/,
|
||||
required: true,
|
||||
},
|
||||
position: {
|
||||
type: 'number',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
|
@ -42,7 +45,7 @@ module.exports = {
|
|||
throw Errors.TASK_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
const values = _.pick(inputs, ['name', 'isCompleted']);
|
||||
const values = _.pick(inputs, ['position', 'name', 'isCompleted']);
|
||||
task = await sails.helpers.tasks.updateOne(task, values, board, this.req);
|
||||
|
||||
if (!task) {
|
||||
|
|
|
@ -5,11 +5,23 @@ module.exports = {
|
|||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
required: true,
|
||||
},
|
||||
exceptTaskIdOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
return sails.helpers.tasks.getMany({
|
||||
const criteria = {
|
||||
cardId: inputs.idOrIds,
|
||||
});
|
||||
};
|
||||
|
||||
if (!_.isUndefined(inputs.exceptTaskIdOrIds)) {
|
||||
criteria.id = {
|
||||
'!=': inputs.exceptTaskIdOrIds,
|
||||
};
|
||||
}
|
||||
|
||||
return sails.helpers.tasks.getMany(criteria);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@ module.exports = {
|
|||
inputs: {
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isPlainObject(value) && _.isFinite(value.position),
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
|
@ -14,8 +15,32 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const tasks = await sails.helpers.cards.getTasks(inputs.card.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
inputs.values.position,
|
||||
tasks,
|
||||
);
|
||||
|
||||
repositions.forEach(async ({ id, position: nextPosition }) => {
|
||||
await Task.update({
|
||||
id,
|
||||
cardId: inputs.card.id,
|
||||
}).set({
|
||||
position: nextPosition,
|
||||
});
|
||||
|
||||
sails.sockets.broadcast(`board:${inputs.card.boardId}`, 'taskUpdate', {
|
||||
item: {
|
||||
id,
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const task = await Task.create({
|
||||
...inputs.values,
|
||||
position,
|
||||
cardId: inputs.card.id,
|
||||
}).fetch();
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
return Task.find(inputs.criteria).sort('id');
|
||||
return Task.find(inputs.criteria).sort('position');
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,6 +6,17 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.position) && !_.isFinite(value.position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
|
@ -18,6 +29,33 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
if (!_.isUndefined(inputs.values.position)) {
|
||||
const tasks = await sails.helpers.cards.getTasks(inputs.record.cardId, inputs.record.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
inputs.values.position,
|
||||
tasks,
|
||||
);
|
||||
|
||||
inputs.values.position = position; // eslint-disable-line no-param-reassign
|
||||
|
||||
repositions.forEach(async ({ id, position: nextPosition }) => {
|
||||
await Task.update({
|
||||
id,
|
||||
cardId: inputs.record.cardId,
|
||||
}).set({
|
||||
position: nextPosition,
|
||||
});
|
||||
|
||||
sails.sockets.broadcast(`board:${inputs.board.id}`, 'taskUpdate', {
|
||||
item: {
|
||||
id,
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const task = await Task.updateOne(inputs.record.id).set(inputs.values);
|
||||
|
||||
if (task) {
|
||||
|
|
|
@ -11,6 +11,10 @@ module.exports = {
|
|||
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
|
||||
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
|
||||
|
||||
position: {
|
||||
type: 'number',
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue