1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 05:09:43 +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 7956503a46
commit fe91b5241e
478 changed files with 21226 additions and 19495 deletions

View file

@ -0,0 +1,47 @@
module.exports = {
inputs: {
values: {
type: 'json',
required: true,
},
user: {
type: 'ref',
required: true,
},
card: {
type: 'ref',
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
const action = await Action.create({
...inputs.values,
cardId: inputs.card.id,
userId: inputs.user.id,
}).fetch();
sails.sockets.broadcast(
`board:${inputs.card.boardId}`,
'actionCreate',
{
item: action,
},
inputs.request,
);
const subscriptionUserIds = await sails.helpers.cards.getSubscriptionUserIds(
action.cardId,
action.userId,
);
subscriptionUserIds.forEach(async (userId) => {
await sails.helpers.notifications.createOne(userId, action);
});
return action;
},
};

View file

@ -0,0 +1,32 @@
module.exports = {
inputs: {
record: {
type: 'ref',
required: true,
},
board: {
type: 'ref',
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
const action = await Action.archiveOne(inputs.record.id);
if (action) {
sails.sockets.broadcast(
`board:${inputs.board.id}`,
'actionDelete',
{
item: action,
},
inputs.request,
);
}
return action;
},
};

View file

@ -0,0 +1,15 @@
module.exports = {
inputs: {
criteria: {
type: 'json',
custom: (value) => _.isArray(value) || _.isPlainObject(value),
},
limit: {
type: 'number',
},
},
async fn(inputs) {
return Action.find(inputs.criteria).sort('id DESC').limit(inputs.limit);
},
};

View file

@ -0,0 +1,34 @@
module.exports = {
inputs: {
criteria: {
type: 'json',
required: true,
},
},
exits: {
pathNotFound: {},
},
async fn(inputs) {
const action = await Action.findOne(inputs.criteria);
if (!action) {
throw 'pathNotFound';
}
const path = await sails.helpers.cards
.getProjectPath(action.cardId)
.intercept('pathNotFound', (nodes) => ({
pathNotFound: {
action,
...nodes,
},
}));
return {
action,
...path,
};
},
};

View file

@ -0,0 +1,36 @@
module.exports = {
inputs: {
record: {
type: 'ref',
required: true,
},
values: {
type: 'json',
required: true,
},
board: {
type: 'ref',
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
const action = await Action.updateOne(inputs.record.id).set(inputs.values);
if (action) {
sails.sockets.broadcast(
`board:${inputs.board.id}`,
'actionUpdate',
{
item: action,
},
inputs.request,
);
}
return action;
},
};