mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
44 lines
679 B
JavaScript
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;
|
|
},
|
|
};
|