mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
parent
a6a836c9a0
commit
f8f2d7345e
27 changed files with 341 additions and 94 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue