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/labels/create-one.js
2022-12-26 21:10:50 +01:00

44 lines
679 B
JavaScript

const valuesValidator = (value) => {
if (!_.isPlainObject(value)) {
return false;
}
if (!_.isPlainObject(value.board)) {
return false;
}
return true;
};
module.exports = {
inputs: {
values: {
type: 'ref',
custom: valuesValidator,
required: true,
},
request: {
type: 'ref',
},
},
async fn(inputs) {
const { values } = inputs;
const label = await Label.create({
...values,
boardId: values.board.id,
}).fetch();
sails.sockets.broadcast(
`board:${label.boardId}`,
'labelCreate',
{
item: label,
},
inputs.request,
);
return label;
},
};