1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-24 15:49:46 +02:00

Project managers, board members, auto-update after reconnection, refactoring

This commit is contained in:
Maksim Eltyshev 2021-06-24 01:05:22 +05:00
parent d6cb1f6683
commit b39119ace4
478 changed files with 21226 additions and 19495 deletions

View file

@ -1,79 +0,0 @@
module.exports = {
inputs: {
record: {
type: 'ref',
required: true,
},
values: {
type: 'json',
custom: (value) => {
if (!_.isPlainObject(value)) {
return false;
}
if (!_.isUndefined(value.position) && !_.isFinite(value.position)) {
return false;
}
return true;
},
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs, exits) {
const userIds = await sails.helpers.getMembershipUserIdsForProject(inputs.record.projectId);
if (!_.isUndefined(inputs.values.position)) {
const boards = await sails.helpers.getBoardsForProject(
inputs.record.projectId,
inputs.record.id,
);
const { position, repositions } = sails.helpers.insertToPositionables(
inputs.values.position,
boards,
);
inputs.values.position = position; // eslint-disable-line no-param-reassign
repositions.forEach(async ({ id, position: nextPosition }) => {
await Board.update({
id,
projectId: inputs.record.projectId,
}).set({
position: nextPosition,
});
userIds.forEach((userId) => {
sails.sockets.broadcast(`user:${userId}`, 'boardUpdate', {
item: {
id,
position: nextPosition,
},
});
});
});
}
const board = await Board.updateOne(inputs.record.id).set(inputs.values);
if (board) {
userIds.forEach((userId) => {
sails.sockets.broadcast(
`user:${userId}`,
'boardUpdate',
{
item: board,
},
inputs.request,
);
});
}
return exits.success(board);
},
};