2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
|
|
|
inputs: {
|
|
|
|
card: {
|
|
|
|
type: 'ref',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
label: {
|
|
|
|
type: 'ref',
|
2019-11-05 18:01:42 +05:00
|
|
|
required: true,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
request: {
|
2019-11-05 18:01:42 +05:00
|
|
|
type: 'ref',
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
2020-04-03 00:35:25 +05:00
|
|
|
exits: {
|
|
|
|
labelAlreadyInCard: {},
|
|
|
|
},
|
|
|
|
|
2019-11-05 18:01:42 +05:00
|
|
|
async fn(inputs, exits) {
|
2019-08-31 04:07:25 +05:00
|
|
|
const cardLabel = await CardLabel.create({
|
|
|
|
cardId: inputs.card.id,
|
2019-11-05 18:01:42 +05:00
|
|
|
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',
|
|
|
|
{
|
2019-11-05 18:01:42 +05:00
|
|
|
item: cardLabel,
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2019-11-05 18:01:42 +05:00
|
|
|
inputs.request,
|
2019-08-31 04:07:25 +05:00
|
|
|
);
|
|
|
|
|
|
|
|
return exits.success(cardLabel);
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|