mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 15:49:46 +02:00
ref: Little refactoring
This commit is contained in:
parent
70cadcd974
commit
3aba4d4a56
14 changed files with 123 additions and 52 deletions
|
@ -15,6 +15,9 @@ const Errors = {
|
|||
LINKED_CARD_NOT_FOUND: {
|
||||
linkedCardNotFound: 'Linked card not found',
|
||||
},
|
||||
LINKED_CARD_OR_NAME_MUST_BE_PRESENT: {
|
||||
linkedCardOrNameMustBePresent: 'Linked card or name must be present',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -31,8 +34,9 @@ module.exports = {
|
|||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
maxLength: 1024,
|
||||
// required: true,
|
||||
allowNull: true,
|
||||
},
|
||||
isCompleted: {
|
||||
type: 'boolean',
|
||||
|
@ -49,6 +53,9 @@ module.exports = {
|
|||
linkedCardNotFound: {
|
||||
responseType: 'notFound',
|
||||
},
|
||||
linkedCardOrNameMustBePresent: {
|
||||
responseType: 'unprocessableEntity',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
|
@ -100,19 +107,24 @@ module.exports = {
|
|||
|
||||
const values = _.pick(inputs, ['position', 'name', 'isCompleted']);
|
||||
|
||||
const task = await sails.helpers.tasks.createOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
values: {
|
||||
...values,
|
||||
taskList,
|
||||
linkedCard,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
const task = await sails.helpers.tasks.createOne
|
||||
.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
values: {
|
||||
...values,
|
||||
taskList,
|
||||
linkedCard,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept(
|
||||
'linkedCardOrNameMustBeInValues',
|
||||
() => Errors.LINKED_CARD_OR_NAME_MUST_BE_PRESENT,
|
||||
);
|
||||
|
||||
return {
|
||||
item: task,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue