1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/api/helpers/create-card-label.js

40 lines
665 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
module.exports = {
inputs: {
card: {
type: 'ref',
required: true,
2019-08-31 04:07:25 +05:00
},
label: {
type: 'ref',
required: true,
2019-08-31 04:07:25 +05:00
},
request: {
type: 'ref',
},
2019-08-31 04:07:25 +05:00
},
2020-04-03 00:35:25 +05:00
exits: {
labelAlreadyInCard: {},
},
async fn(inputs, exits) {
2019-08-31 04:07:25 +05:00
const cardLabel = await CardLabel.create({
cardId: inputs.card.id,
labelId: inputs.label.id,
2019-08-31 04:07:25 +05:00
})
2020-04-03 00:35:25 +05:00
.intercept('E_UNIQUE', 'labelAlreadyInCard')
2019-08-31 04:07:25 +05:00
.fetch();
sails.sockets.broadcast(
`board:${inputs.card.boardId}`,
'cardLabelCreate',
{
item: cardLabel,
2019-08-31 04:07:25 +05:00
},
inputs.request,
2019-08-31 04:07:25 +05:00
);
return exits.success(cardLabel);
},
2019-08-31 04:07:25 +05:00
};