1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

feat: Version 2

Closes #627, closes #1047
This commit is contained in:
Maksim Eltyshev 2025-05-10 02:09:06 +02:00
parent ad7fb51cfa
commit 2ee1166747
1557 changed files with 76832 additions and 47042 deletions

View file

@ -1,3 +1,10 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const { idInput } = require('../../../utils/inputs');
const Errors = {
PROJECT_NOT_FOUND: {
projectNotFound: 'Project not found',
@ -13,16 +20,17 @@ const Errors = {
module.exports = {
inputs: {
projectId: {
type: 'string',
regex: /^[0-9]+$/,
...idInput,
required: true,
},
position: {
type: 'number',
min: 0,
required: true,
},
name: {
type: 'string',
maxLength: 128,
required: true,
},
importType: {
@ -32,6 +40,7 @@ module.exports = {
requestId: {
type: 'string',
isNotEmptyString: true,
maxLength: 128,
},
},
@ -42,6 +51,9 @@ module.exports = {
noImportFileWasUploaded: {
responseType: 'unprocessableEntity',
},
invalidImportFile: {
responseType: 'unprocessableEntity',
},
uploadError: {
responseType: 'unprocessableEntity',
},
@ -50,7 +62,7 @@ module.exports = {
async fn(inputs) {
const { currentUser } = this.req;
const project = await Project.findOne(inputs.projectId);
const project = await Project.qm.getOneById(inputs.projectId);
if (!project) {
throw Errors.PROJECT_NOT_FOUND;
@ -62,10 +74,8 @@ module.exports = {
throw Errors.PROJECT_NOT_FOUND; // Forbidden
}
const values = _.pick(inputs, ['position', 'name']);
let boardImport;
if (inputs.importType && Object.values(Board.ImportTypes).includes(inputs.importType)) {
if (inputs.importType) {
let files;
try {
files = await sails.helpers.utils.receiveFile('importFile', this.req);
@ -80,13 +90,19 @@ module.exports = {
const file = _.last(files);
if (inputs.importType === Board.ImportTypes.TRELLO) {
const trelloBoard = await sails.helpers.boards
.processUploadedTrelloImportFile(file)
.intercept('invalidFile', () => Errors.INVALID_IMPORT_FILE);
boardImport = {
type: inputs.importType,
board: await sails.helpers.boards.processUploadedTrelloImportFile(file),
board: trelloBoard,
};
}
}
const values = _.pick(inputs, ['position', 'name']);
const { board, boardMembership } = await sails.helpers.boards.createOne.with({
values: {
...values,