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:
parent
7956503a46
commit
fe91b5241e
478 changed files with 21226 additions and 19495 deletions
47
server/api/helpers/actions/create-one.js
Normal file
47
server/api/helpers/actions/create-one.js
Normal 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;
|
||||
},
|
||||
};
|
32
server/api/helpers/actions/delete-one.js
Normal file
32
server/api/helpers/actions/delete-one.js
Normal 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;
|
||||
},
|
||||
};
|
15
server/api/helpers/actions/get-many.js
Normal file
15
server/api/helpers/actions/get-many.js
Normal 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);
|
||||
},
|
||||
};
|
34
server/api/helpers/actions/get-project-path.js
Normal file
34
server/api/helpers/actions/get-project-path.js
Normal 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,
|
||||
};
|
||||
},
|
||||
};
|
36
server/api/helpers/actions/update-one.js
Normal file
36
server/api/helpers/actions/update-one.js
Normal 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;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue