mirror of
https://github.com/plankanban/planka.git
synced 2025-07-22 22:59:44 +02:00
Code formatting with prettier, change eslint config for the server
This commit is contained in:
parent
b7f37f0f96
commit
a11f6260c0
191 changed files with 4321 additions and 2880 deletions
|
@ -2,11 +2,11 @@ const moment = require('moment');
|
|||
|
||||
const Errors = {
|
||||
CARD_NOT_FOUND: {
|
||||
notFound: 'Card is not found'
|
||||
notFound: 'Card is not found',
|
||||
},
|
||||
LIST_NOT_FOUND: {
|
||||
notFound: 'List is not found'
|
||||
}
|
||||
notFound: 'List is not found',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
@ -14,59 +14,60 @@ module.exports = {
|
|||
id: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
regex: /^[0-9]+$/
|
||||
regex: /^[0-9]+$/,
|
||||
},
|
||||
position: {
|
||||
type: 'number'
|
||||
type: 'number',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true
|
||||
isNotEmptyString: true,
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
allowNull: true
|
||||
allowNull: true,
|
||||
},
|
||||
dueDate: {
|
||||
type: 'string',
|
||||
custom: value => moment(value, moment.ISO_8601, true).isValid(),
|
||||
allowNull: true
|
||||
custom: (value) => moment(value, moment.ISO_8601, true).isValid(),
|
||||
allowNull: true,
|
||||
},
|
||||
timer: {
|
||||
type: 'json',
|
||||
custom: value =>
|
||||
_.isPlainObject(value) &&
|
||||
_.size(value) === 2 &&
|
||||
(_.isNull(value.startedAt) ||
|
||||
moment(value.startedAt, moment.ISO_8601, true).isValid()) &&
|
||||
_.isFinite(value.total)
|
||||
custom: (value) => _.isPlainObject(value)
|
||||
&& _.size(value) === 2
|
||||
&& (_.isNull(value.startedAt) || moment(value.startedAt, moment.ISO_8601, true).isValid())
|
||||
&& _.isFinite(value.total),
|
||||
},
|
||||
isSubscribed: {
|
||||
type: 'boolean'
|
||||
}
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
notFound: {
|
||||
responseType: 'notFound'
|
||||
}
|
||||
responseType: 'notFound',
|
||||
},
|
||||
},
|
||||
|
||||
fn: async function(inputs, exits) {
|
||||
async fn(inputs, exits) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { card, list, project } = await sails.helpers
|
||||
const cardToProjectPath = await sails.helpers
|
||||
.getCardToProjectPath(inputs.id)
|
||||
.intercept('notFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
let { card } = cardToProjectPath;
|
||||
const { list, project } = cardToProjectPath;
|
||||
|
||||
const isUserMemberForProject = await sails.helpers.isUserMemberForProject(
|
||||
project.id,
|
||||
currentUser.id
|
||||
currentUser.id,
|
||||
);
|
||||
|
||||
if (!isUserMemberForProject) {
|
||||
|
@ -77,7 +78,7 @@ module.exports = {
|
|||
if (!_.isUndefined(inputs.listId) && inputs.listId !== list.id) {
|
||||
toList = await List.findOne({
|
||||
id: inputs.listId,
|
||||
boardId: card.boardId
|
||||
boardId: card.boardId,
|
||||
});
|
||||
|
||||
if (!toList) {
|
||||
|
@ -91,24 +92,17 @@ module.exports = {
|
|||
'description',
|
||||
'dueDate',
|
||||
'timer',
|
||||
'isSubscribed'
|
||||
'isSubscribed',
|
||||
]);
|
||||
|
||||
card = await sails.helpers.updateCard(
|
||||
card,
|
||||
values,
|
||||
toList,
|
||||
list,
|
||||
currentUser,
|
||||
this.req
|
||||
);
|
||||
card = await sails.helpers.updateCard(card, values, toList, list, currentUser, this.req);
|
||||
|
||||
if (!card) {
|
||||
throw Errors.CARD_NOT_FOUND;
|
||||
}
|
||||
|
||||
return exits.success({
|
||||
item: card
|
||||
item: card,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue